Software / code / prosody
Comparison
plugins/mod_presence.lua @ 1279:fa00d56a9fd3
mod_presence: Handle all outbound presence stanzas
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 02 Jun 2009 15:53:04 +0500 |
| parent | 1278:2abf85791f29 |
| child | 1280:e360fef8882b |
comparison
equal
deleted
inserted
replaced
| 1278:2abf85791f29 | 1279:fa00d56a9fd3 |
|---|---|
| 270 prosody.events.add_handler(module:get_host().."/presence", presence_handler); | 270 prosody.events.add_handler(module:get_host().."/presence", presence_handler); |
| 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 module:hook("pre-presence/full", function(data) | 275 local outbound_presence_handler = function(data) |
| 276 -- outbound presence to full JID recieved | 276 -- outbound presence to full JID 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 sent to full JID |
| 290 origin.directed[to] = nil; -- FIXME does it make more sense to add to_bare rather than to? | 290 origin.directed[to] = nil; -- FIXME does it make more sense to add to_bare rather than to? |
| 291 else | 291 else |
| 292 origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to? | 292 origin.directed[to] = true; -- FIXME does it make more sense to add to_bare rather than to? |
| 293 end | 293 end |
| 294 end | 294 end |
| 295 end); | 295 end |
| 296 | |
| 297 module:hook("pre-presence/full", outbound_presence_handler); | |
| 298 module:hook("pre-presence/bare", outbound_presence_handler); | |
| 299 module:hook("pre-presence/host", outbound_presence_handler); |