# HG changeset patch # User Waqas Hussain # Date 1243860722 -18000 # Node ID 28f9041d8c5571f7f811fdfb4b93c591b83c4280 # Parent e78c161944ab388ede4e8daa92594a9a851e468c mod_message: Added code to handle error groupchat and headline messages to bare JID diff -r e78c161944ab -r 28f9041d8c55 plugins/mod_message.lua --- a/plugins/mod_message.lua Mon Jun 01 17:36:33 2009 +0500 +++ b/plugins/mod_message.lua Mon Jun 01 17:52:02 2009 +0500 @@ -7,20 +7,38 @@ local function process_to_bare(bare, origin, stanza) local sessions = bare_sessions[bare]; - if sessions then sessions = sessions.sessions; end + local t = stanza.attr.type; + if t == "error" then return true; end + if t == "groupchat" then + origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); + return true; + end + if sessions then - -- some resources are online + -- some resources are connected + sessions = sessions.sessions; + + if t == "headline" then + for _, session in pairs(sessions) do + if session.presence and session.priority >= 0 then + session.send(stanza); + end + end + return true; + end -- TODO find top resources willing to accept this message -- TODO then send them each the stanza - else - -- no resources are online - -- TODO check if the user exists - -- TODO if it doesn't, return an error reply - -- TODO otherwise, apply the default privacy list - -- TODO and store into offline storage - -- TODO or maybe the offline store can apply privacy lists + return; end + -- no resources are online + if t == "headline" then return true; end -- current policy is to discard headlines + -- chat or normal message + -- TODO check if the user exists + -- TODO if it doesn't, return an error reply + -- TODO otherwise, apply the default privacy list + -- TODO and store into offline storage + -- TODO or maybe the offline store can apply privacy lists end module:hook("message/full", function(data)