plugins/mod_presence.lua

changeset 1278
2abf85791f29
parent 1277
f2b50efe8d44
child 1279
fa00d56a9fd3
equal deleted inserted replaced
1277:f2b50efe8d44 1278:2abf85791f29
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 274
275 module:hook("pre-presence/full", function(data) 275 module:hook("pre-presence/full", function(data)
276 -- presence to full JID recieved 276 -- outbound presence to full JID recieved
277 local origin, stanza = data.origin, data.stanza; 277 local origin, stanza = data.origin, data.stanza;
278 278
279 if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then 279 local t = stanza.attr.type;
280 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID
280 handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); 281 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 return true;
282 end 283 end
283 284
284 local to = stanza.attr.to; 285 local to = stanza.attr.to;
285 local to_bare = jid_bare(to); 286 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 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 = origin.directed or {};
288 if stanza.attr.type then -- removing from directed presence list on sending an error or unavailable 289 if t then -- removing from directed presence list on sending an error or unavailable
289 origin.directed[to] = nil; -- FIXME does it make more sense to add to_bare rather than to? 290 origin.directed[to] = nil; -- FIXME does it make more sense to add to_bare rather than to?
290 else 291 else
291 origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to? 292 origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to?
292 end 293 end
293 end 294 end

mercurial