Software / code / prosody
Comparison
plugins/mod_message.lua @ 6054:7a5ddbaf758d
Merge 0.9->0.10
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 02 Apr 2014 17:41:38 +0100 |
| parent | 5776:bd0ff8ae98a8 |
| child | 7718:c58075c4d375 |
comparison
equal
deleted
inserted
replaced
| 6053:2f93a04564b2 | 6054:7a5ddbaf758d |
|---|---|
| 1 -- Prosody IM | 1 -- Prosody IM |
| 2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
| 3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 | 9 |
| 15 local jid_split = require "util.jid".split; | 15 local jid_split = require "util.jid".split; |
| 16 local user_exists = require "core.usermanager".user_exists; | 16 local user_exists = require "core.usermanager".user_exists; |
| 17 | 17 |
| 18 local function process_to_bare(bare, origin, stanza) | 18 local function process_to_bare(bare, origin, stanza) |
| 19 local user = bare_sessions[bare]; | 19 local user = bare_sessions[bare]; |
| 20 | 20 |
| 21 local t = stanza.attr.type; | 21 local t = stanza.attr.type; |
| 22 if t == "error" then | 22 if t == "error" then |
| 23 -- discard | 23 -- discard |
| 24 elseif t == "groupchat" then | 24 elseif t == "groupchat" then |
| 25 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | 25 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); |
| 64 end | 64 end |
| 65 | 65 |
| 66 module:hook("message/full", function(data) | 66 module:hook("message/full", function(data) |
| 67 -- message to full JID recieved | 67 -- message to full JID recieved |
| 68 local origin, stanza = data.origin, data.stanza; | 68 local origin, stanza = data.origin, data.stanza; |
| 69 | 69 |
| 70 local session = full_sessions[stanza.attr.to]; | 70 local session = full_sessions[stanza.attr.to]; |
| 71 if session and session.send(stanza) then | 71 if session and session.send(stanza) then |
| 72 return true; | 72 return true; |
| 73 else -- resource not online | 73 else -- resource not online |
| 74 return process_to_bare(jid_bare(stanza.attr.to), origin, stanza); | 74 return process_to_bare(jid_bare(stanza.attr.to), origin, stanza); |