Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 1282:ff58ef687a3f
mod_presence: Handle subscriptions and probes
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 02 Jun 2009 16:06:02 +0500 |
| parents | bc65d57c76ef |
| children | 2e57f2176612 |
comparison
equal
deleted
inserted
replaced
| 1281:bc65d57c76ef | 1282:ff58ef687a3f |
|---|---|
| 271 module.unload = function() | 271 module.unload = function() |
| 272 prosody.events.remove_handler(module:get_host().."/presence", presence_handler); | 272 prosody.events.remove_handler(module:get_host().."/presence", presence_handler); |
| 273 end | 273 end |
| 274 | 274 |
| 275 local outbound_presence_handler = function(data) | 275 local outbound_presence_handler = function(data) |
| 276 -- outbound presence to recieved | 276 -- outbound presence recieved |
| 277 local origin, stanza = data.origin, data.stanza; | 277 local origin, stanza = data.origin, data.stanza; |
| 278 | 278 |
| 279 local t = stanza.attr.type; | 279 local t = stanza.attr.type; |
| 280 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID | 280 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes |
| 281 handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); | 281 handle_outbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); |
| 282 return true; | 282 return true; |
| 283 end | 283 end |
| 284 | 284 |
| 285 local to = stanza.attr.to; | 285 local to = stanza.attr.to; |
| 299 module:hook("pre-presence/host", outbound_presence_handler); | 299 module:hook("pre-presence/host", outbound_presence_handler); |
| 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 | |
| 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 | |
| 304 end); | 310 end); |
| 305 module:hook("presence/full", function(data) | 311 module:hook("presence/full", function(data) |
| 306 -- inbound presence to full JID recieved | 312 -- inbound presence to full JID recieved |
| 307 local origin, stanza = data.origin, data.stanza; | 313 local origin, stanza = data.origin, data.stanza; |
| 314 | |
| 315 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 | |
| 317 handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); | |
| 318 return true; | |
| 319 end | |
| 308 end); | 320 end); |
