Mercurial > prosody-modules
comparison mod_sift/mod_sift.lua @ 142:f37de7e2ad14
mod_sift: Iterate on user sessions, not on the user itself, when sifting stanzas to bare JIDs.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 06 Mar 2010 22:32:12 +0500 |
parents | b42a88eba9ba |
children | 7dbde05b48a9 |
comparison
equal
deleted
inserted
replaced
141:b42a88eba9ba | 142:f37de7e2ad14 |
---|---|
129 -- Message to bare JID handler | 129 -- Message to bare JID handler |
130 module:hook("message/bare", function(event) | 130 module:hook("message/bare", function(event) |
131 local origin, stanza = event.origin, event.stanza; | 131 local origin, stanza = event.origin, event.stanza; |
132 local user = bare_sessions[jid_bare(stanza.attr.to)]; | 132 local user = bare_sessions[jid_bare(stanza.attr.to)]; |
133 local allowed = false; | 133 local allowed = false; |
134 for _, session in pairs(user or {}) do | 134 for _, session in pairs(user and user.sessions or {}) do |
135 local siftdata = data[session.full_jid]; | 135 local siftdata = data[session.full_jid]; |
136 if siftdata and siftdata.message then -- we seem to have an message filter | 136 if siftdata and siftdata.message then -- we seem to have an message filter |
137 for _, childtag in ipairs(stanza.tags) do | 137 for _, childtag in ipairs(stanza.tags) do |
138 if siftdata.message[(childtag.attr.xmlns or "jabber:client").."|"..childtag.name] then | 138 if siftdata.message[(childtag.attr.xmlns or "jabber:client").."|"..childtag.name] then |
139 allowed = true; | 139 allowed = true; |
173 -- Presence to bare JID handler | 173 -- Presence to bare JID handler |
174 module:hook("presence/bare", function(event) | 174 module:hook("presence/bare", function(event) |
175 local origin, stanza = event.origin, event.stanza; | 175 local origin, stanza = event.origin, event.stanza; |
176 local user = bare_sessions[jid_bare(stanza.attr.to)]; | 176 local user = bare_sessions[jid_bare(stanza.attr.to)]; |
177 local allowed = false; | 177 local allowed = false; |
178 for _, session in pairs(user or {}) do | 178 for _, session in pairs(user and user.sessions or {}) do |
179 local siftdata = data[session.full_jid]; | 179 local siftdata = data[session.full_jid]; |
180 if siftdata and siftdata.presence then -- we seem to have an presence filter | 180 if siftdata and siftdata.presence then -- we seem to have an presence filter |
181 for _, childtag in ipairs(stanza.tags) do | 181 for _, childtag in ipairs(stanza.tags) do |
182 if siftdata.presence[(childtag.attr.xmlns or "jabber:client").."|"..childtag.name] then | 182 if siftdata.presence[(childtag.attr.xmlns or "jabber:client").."|"..childtag.name] then |
183 allowed = true; | 183 allowed = true; |