aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-06-02 07:22:16 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-06-02 07:22:16 +0500
commita039878df668ca0563fa712322b20326eb91fa8b (patch)
treeb683186c8d71981dc5620d8e5b42babe84e72d35 /plugins
parentdad6d48b8ecb25d16dc932984cb21aff33555d01 (diff)
downloadprosody-a039878df668ca0563fa712322b20326eb91fa8b.tar.gz
prosody-a039878df668ca0563fa712322b20326eb91fa8b.zip
mod_presence: Handle outbound presence to full JIDs
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_presence.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua
index ba71b940..468fbd98 100644
--- a/plugins/mod_presence.lua
+++ b/plugins/mod_presence.lua
@@ -271,3 +271,20 @@ prosody.events.add_handler(module:get_host().."/presence", presence_handler);
module.unload = function()
prosody.events.remove_handler(module:get_host().."/presence", presence_handler);
end
+
+module:hook("pre-presence/full", function(data)
+ -- presence to full JID recieved
+ local origin, stanza = data.origin, data.stanza;
+
+ if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then
+ handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
+ return true;
+ end
+
+ local to = stanza.attr.to;
+ local to_bare = jid_bare(to);
+ if not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then -- directed presence
+ origin.directed = origin.directed or {};
+ origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to?
+ end
+end);