Software /
code /
prosody
Diff
plugins/mod_message.lua @ 1275:850cf92b8ad4
mod_message: A little cleanup
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 01 Jun 2009 18:15:28 +0500 |
parent | 1274:50babb72edac |
child | 1289:d0c38cac1687 |
line wrap: on
line diff
--- a/plugins/mod_message.lua Mon Jun 01 18:11:01 2009 +0500 +++ b/plugins/mod_message.lua Mon Jun 01 18:15:28 2009 +0500 @@ -11,6 +11,7 @@ local recipients = {}; for _, session in pairs(user.sessions) do -- find resource with greatest priority if session.presence then + -- TODO check active privacy list for session local p = session.priority; if p > priority then priority = p; @@ -27,12 +28,11 @@ local user = bare_sessions[bare]; local t = stanza.attr.type; - if t == "error" then return true; end - if t == "groupchat" then + if t == "error" then + -- discard + elseif t == "groupchat" then origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); - return true; - end - if t == "headline" then + elseif t == "headline" then if user then for _, session in pairs(user.sessions) do if session.presence and session.priority >= 0 then @@ -40,25 +40,24 @@ end end end -- current policy is to discard headlines if no recipient is available - return true; - end - -- chat or normal message - if user then -- some resources are connected - local recipients = select_top_resources(user); - if #recipients > 0 then - for i=1,#recipients do - recipients[i].send(stanza); + else -- chat or normal message + if user then -- some resources are connected + local recipients = select_top_resources(user); + if #recipients > 0 then + for i=1,#recipients do + recipients[i].send(stanza); + end + return true; end - return true; end - end - -- no resources are online - local node, host = jid_split(bare); - if user_exists(node, host) then - -- TODO apply the default privacy list - offlinemanager.store(node, host, stanza); - else - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); + -- no resources are online + local node, host = jid_split(bare); + if user_exists(node, host) then + -- TODO apply the default privacy list + offlinemanager.store(node, host, stanza); + else + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); + end end return true; end