Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 1285:0a6e2d6ae459
mod_presence: Check for nil 'to' attribute in all cases for incoming stanzas
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 02 Jun 2009 20:07:22 +0500 |
| parents | c0fb8379696e |
| children | a9b1675ad16e |
comparison
equal
deleted
inserted
replaced
| 1284:c0fb8379696e | 1285:0a6e2d6ae459 |
|---|---|
| 300 | 300 |
| 301 module:hook("presence/bare", function(data) | 301 module:hook("presence/bare", function(data) |
| 302 -- inbound presence to bare JID recieved | 302 -- inbound presence to bare JID recieved |
| 303 local origin, stanza = data.origin, data.stanza; | 303 local origin, stanza = data.origin, data.stanza; |
| 304 | 304 |
| 305 local t = stanza.attr.type; | |
| 306 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID | |
| 307 handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); | |
| 308 return true; | |
| 309 end | |
| 310 | |
| 311 local to = stanza.attr.to; | 305 local to = stanza.attr.to; |
| 312 if to then | 306 if to then |
| 307 local t = stanza.attr.type; | |
| 308 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID | |
| 309 handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); | |
| 310 return true; | |
| 311 end | |
| 312 | |
| 313 local user = bare_sessions[to]; | 313 local user = bare_sessions[to]; |
| 314 if user then | 314 if user then |
| 315 for _, session in pairs(user.sessions) do | 315 for _, session in pairs(user.sessions) do |
| 316 if session.presence then -- only send to available resources | 316 if session.presence then -- only send to available resources |
| 317 session.send(stanza); | 317 session.send(stanza); |
| 318 end | 318 end |
| 319 end | 319 end |
| 320 end -- no resources not online, discard | 320 end -- no resources not online, discard |
| 321 else | 321 elseif not t or t == "unavailable" then |
| 322 handle_normal_presence(origin, stanza, core_route_stanza); | 322 handle_normal_presence(origin, stanza, core_route_stanza); |
| 323 end | 323 end |
| 324 return true; | 324 return true; |
| 325 end); | 325 end); |
| 326 module:hook("presence/full", function(data) | 326 module:hook("presence/full", function(data) |
