269 |
269 |
270 prosody.events.add_handler(module:get_host().."/presence", presence_handler); |
270 prosody.events.add_handler(module:get_host().."/presence", presence_handler); |
271 module.unload = function() |
271 module.unload = function() |
272 prosody.events.remove_handler(module:get_host().."/presence", presence_handler); |
272 prosody.events.remove_handler(module:get_host().."/presence", presence_handler); |
273 end |
273 end |
|
274 |
|
275 module:hook("pre-presence/full", function(data) |
|
276 -- presence to full JID recieved |
|
277 local origin, stanza = data.origin, data.stanza; |
|
278 |
|
279 if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then |
|
280 handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); |
|
281 return true; |
|
282 end |
|
283 |
|
284 local to = stanza.attr.to; |
|
285 local to_bare = jid_bare(to); |
|
286 if not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then -- directed presence |
|
287 origin.directed = origin.directed or {}; |
|
288 origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to? |
|
289 end |
|
290 end); |