Software / code / prosody
Comparison
plugins/mod_iq.lua @ 3131:5c116a10ff0b
mod_iq: Removed a check for user existance when firing iq/bare/* sub-events.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 30 May 2010 23:01:34 +0500 |
| parent | 2925:692b3c6c5bd2 |
| child | 3647:140ce81778ca |
comparison
equal
deleted
inserted
replaced
| 3130:80e630e60f06 | 3131:5c116a10ff0b |
|---|---|
| 7 -- | 7 -- |
| 8 | 8 |
| 9 | 9 |
| 10 local st = require "util.stanza"; | 10 local st = require "util.stanza"; |
| 11 local jid_split = require "util.jid".split; | 11 local jid_split = require "util.jid".split; |
| 12 local user_exists = require "core.usermanager".user_exists; | |
| 13 | 12 |
| 14 local full_sessions = full_sessions; | 13 local full_sessions = full_sessions; |
| 15 local bare_sessions = bare_sessions; | 14 local bare_sessions = bare_sessions; |
| 16 | 15 |
| 17 module:hook("iq/full", function(data) | 16 module:hook("iq/full", function(data) |
| 32 | 31 |
| 33 module:hook("iq/bare", function(data) | 32 module:hook("iq/bare", function(data) |
| 34 -- IQ to bare JID recieved | 33 -- IQ to bare JID recieved |
| 35 local origin, stanza = data.origin, data.stanza; | 34 local origin, stanza = data.origin, data.stanza; |
| 36 | 35 |
| 37 local to = stanza.attr.to; | |
| 38 if to and not bare_sessions[to] then -- quick check for account existance | |
| 39 local node, host = jid_split(to); | |
| 40 if not user_exists(node, host) then -- full check for account existance | |
| 41 if stanza.attr.type == "get" or stanza.attr.type == "set" then | |
| 42 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | |
| 43 end | |
| 44 return true; | |
| 45 end | |
| 46 end | |
| 47 -- TODO fire post processing events | 36 -- TODO fire post processing events |
| 48 if stanza.attr.type == "get" or stanza.attr.type == "set" then | 37 if stanza.attr.type == "get" or stanza.attr.type == "set" then |
| 49 return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | 38 return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); |
| 50 else | 39 else |
| 51 module:fire_event("iq/bare/"..stanza.attr.id, data); | 40 module:fire_event("iq/bare/"..stanza.attr.id, data); |