Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 1283:2e57f2176612
mod_presence: Handle non-subscription presence and routing
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 02 Jun 2009 16:21:20 +0500 |
| parents | ff58ef687a3f |
| children | c0fb8379696e |
comparison
equal
deleted
inserted
replaced
| 1282:ff58ef687a3f | 1283:2e57f2176612 |
|---|---|
| 305 local t = stanza.attr.type; | 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 | 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); | 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; | 308 return true; |
| 309 end | 309 end |
| 310 | |
| 311 local to = stanza.attr.to; | |
| 312 if to then | |
| 313 local user = bare_sessions[to]; | |
| 314 if user then | |
| 315 for _, session in pairs(user.sessions) do | |
| 316 if session.presence then -- only send to available resources | |
| 317 session.send(stanza); | |
| 318 end | |
| 319 end | |
| 320 end -- no resources not online, discard | |
| 321 else | |
| 322 handle_normal_presence(origin, stanza, core_route_stanza); | |
| 323 end | |
| 310 end); | 324 end); |
| 311 module:hook("presence/full", function(data) | 325 module:hook("presence/full", function(data) |
| 312 -- inbound presence to full JID recieved | 326 -- inbound presence to full JID recieved |
| 313 local origin, stanza = data.origin, data.stanza; | 327 local origin, stanza = data.origin, data.stanza; |
| 314 | 328 |
| 315 local t = stanza.attr.type; | 329 local t = stanza.attr.type; |
| 316 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID | 330 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID |
| 317 handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); | 331 handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); |
| 318 return true; | 332 return true; |
| 319 end | 333 end |
| 334 | |
| 335 local session = full_sessions[stanza.attr.to]; | |
| 336 if session then | |
| 337 -- TODO fire post processing event | |
| 338 session.send(stanza); | |
| 339 end -- resource not online, discard | |
| 320 end); | 340 end); |
