Software /
code /
prosody
Diff
plugins/mod_presence.lua @ 1286:a9b1675ad16e
mod_presence: Check for nil 'to' attribute in all cases for outgoing stanzas
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 02 Jun 2009 20:10:25 +0500 |
parent | 1285:0a6e2d6ae459 |
child | 1287:ac82c7b9c76b |
line wrap: on
line diff
--- a/plugins/mod_presence.lua Tue Jun 02 20:07:22 2009 +0500 +++ b/plugins/mod_presence.lua Tue Jun 02 20:10:25 2009 +0500 @@ -276,22 +276,24 @@ -- 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; + 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 - 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? + 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 + end -- TODO maybe handle normal presence here, instead of letting it pass to incoming handlers? end module:hook("pre-presence/full", outbound_presence_handler);