diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-06-01 18:15:28 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-06-01 18:15:28 +0500 |
commit | dad6d48b8ecb25d16dc932984cb21aff33555d01 (patch) | |
tree | 2aa2053e4b57d8f5001e61cad8532e847b1fbc67 | |
parent | 01c198ae630807e6e483a938d4657fbe773ead8b (diff) | |
download | prosody-dad6d48b8ecb25d16dc932984cb21aff33555d01.tar.gz prosody-dad6d48b8ecb25d16dc932984cb21aff33555d01.zip |
mod_message: A little cleanup
-rw-r--r-- | plugins/mod_message.lua | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/plugins/mod_message.lua b/plugins/mod_message.lua index fc3ecbd7..621d5660 100644 --- a/plugins/mod_message.lua +++ b/plugins/mod_message.lua @@ -11,6 +11,7 @@ local function select_top_resources(user) 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 function process_to_bare(bare, origin, stanza) 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 @@ local function process_to_bare(bare, origin, stanza) 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 |