Comparison

plugins/mod_presence.lua @ 1276:d0e80c1578e1

mod_presence: Handle outbound presence to full JIDs
author Waqas Hussain <waqas20@gmail.com>
date Tue, 02 Jun 2009 07:22:16 +0500
parent 1245:be5fe60bd866
child 1277:f2b50efe8d44
comparison
equal deleted inserted replaced
1275:850cf92b8ad4 1276:d0e80c1578e1
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);