Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 4175:48fb768fe760
mod_presence: Bounce errors for invalid presence types (thanks nolan/Astro)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 10 Feb 2011 21:09:20 +0000 |
| parents | 5262d3eb7f01 |
| children | b7bcf088e723 |
comparison
equal
deleted
inserted
replaced
| 4174:6334ff60e1f6 | 4175:48fb768fe760 |
|---|---|
| 201 -- 2. roster push (subscription = none or to) | 201 -- 2. roster push (subscription = none or to) |
| 202 if rostermanager.unsubscribed(node, host, to_bare) then | 202 if rostermanager.unsubscribed(node, host, to_bare) then |
| 203 rostermanager.roster_push(node, host, to_bare); | 203 rostermanager.roster_push(node, host, to_bare); |
| 204 end | 204 end |
| 205 core_post_stanza(origin, stanza); | 205 core_post_stanza(origin, stanza); |
| 206 else | |
| 207 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type")); | |
| 206 end | 208 end |
| 207 stanza.attr.from, stanza.attr.to = st_from, st_to; | 209 stanza.attr.from, stanza.attr.to = st_from, st_to; |
| 208 return true; | 210 return true; |
| 209 end | 211 end |
| 210 | 212 |
| 251 elseif stanza.attr.type == "unsubscribed" then | 253 elseif stanza.attr.type == "unsubscribed" then |
| 252 if rostermanager.process_inbound_subscription_cancellation(node, host, from_bare) then | 254 if rostermanager.process_inbound_subscription_cancellation(node, host, from_bare) then |
| 253 sessionmanager.send_to_interested_resources(node, host, stanza); | 255 sessionmanager.send_to_interested_resources(node, host, stanza); |
| 254 rostermanager.roster_push(node, host, from_bare); | 256 rostermanager.roster_push(node, host, from_bare); |
| 255 end | 257 end |
| 256 end -- discard any other type | 258 else |
| 259 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type")); | |
| 260 end | |
| 257 stanza.attr.from, stanza.attr.to = st_from, st_to; | 261 stanza.attr.from, stanza.attr.to = st_from, st_to; |
| 258 return true; | 262 return true; |
| 259 end | 263 end |
| 260 | 264 |
| 261 local outbound_presence_handler = function(data) | 265 local outbound_presence_handler = function(data) |
| 305 end | 309 end |
| 306 end | 310 end |
| 307 end -- no resources not online, discard | 311 end -- no resources not online, discard |
| 308 elseif not t or t == "unavailable" then | 312 elseif not t or t == "unavailable" then |
| 309 handle_normal_presence(origin, stanza); | 313 handle_normal_presence(origin, stanza); |
| 314 else | |
| 315 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type")); | |
| 310 end | 316 end |
| 311 return true; | 317 return true; |
| 312 end); | 318 end); |
| 313 module:hook("presence/full", function(data) | 319 module:hook("presence/full", function(data) |
| 314 -- inbound presence to full JID recieved | 320 -- inbound presence to full JID recieved |
