aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-06-02 20:10:25 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-06-02 20:10:25 +0500
commit028a4979d10da6a1916c4618d48dd7ec4edc9d8b (patch)
treef0db6dfa87ad876a3785edae64329c1f86814d2f /plugins
parent6f05311d94df5373de96264015bcf16cc32a55e7 (diff)
downloadprosody-028a4979d10da6a1916c4618d48dd7ec4edc9d8b.tar.gz
prosody-028a4979d10da6a1916c4618d48dd7ec4edc9d8b.zip
mod_presence: Check for nil 'to' attribute in all cases for outgoing stanzas
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_presence.lua30
1 files changed, 16 insertions, 14 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua
index 1587790d..eb2ccb05 100644
--- a/plugins/mod_presence.lua
+++ b/plugins/mod_presence.lua
@@ -276,22 +276,24 @@ local outbound_presence_handler = function(data)
-- outbound presence recieved
local origin, stanza = data.origin, data.stanza;
- local t = stanza.attr.type;
- if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes
- 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 {};
- if t then -- removing from directed presence list on sending an error or unavailable
- origin.directed[to] = nil; -- FIXME does it make more sense to add to_bare rather than to?
- else
- origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to?
+ if to then
+ local t = stanza.attr.type;
+ if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes
+ handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);
+ return true;
end
- end
+
+ 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 {};
+ if t then -- removing from directed presence list on sending an error or unavailable
+ origin.directed[to] = nil; -- FIXME does it make more sense to add to_bare rather than to?
+ else
+ origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to?
+ end
+ end
+ end -- TODO maybe handle normal presence here, instead of letting it pass to incoming handlers?
end
module:hook("pre-presence/full", outbound_presence_handler);