Comparison

plugins/mod_message.lua @ 4965:c1685f0441b7

mod_message: Don't treat a message as delivered ok if session.send() returns false
author Matthew Wild <mwild1@gmail.com>
date Sun, 22 Jul 2012 16:59:55 +0100
parent 4759:c4a0c420d232
child 5370:7838acadb0fa
comparison
equal deleted inserted replaced
4964:c9b8ec3eb1e9 4965:c1685f0441b7
33 end -- current policy is to discard headlines if no recipient is available 33 end -- current policy is to discard headlines if no recipient is available
34 else -- chat or normal message 34 else -- chat or normal message
35 if user then -- some resources are connected 35 if user then -- some resources are connected
36 local recipients = user.top_resources; 36 local recipients = user.top_resources;
37 if recipients then 37 if recipients then
38 local sent;
38 for i=1,#recipients do 39 for i=1,#recipients do
39 recipients[i].send(stanza); 40 sent = recipients[i].send(stanza) or sent;
40 end 41 end
41 return true; 42 if sent then
43 return true;
44 end
42 end 45 end
43 end 46 end
44 -- no resources are online 47 -- no resources are online
45 local node, host = jid_split(bare); 48 local node, host = jid_split(bare);
46 local ok 49 local ok
63 module:hook("message/full", function(data) 66 module:hook("message/full", function(data)
64 -- message to full JID recieved 67 -- message to full JID recieved
65 local origin, stanza = data.origin, data.stanza; 68 local origin, stanza = data.origin, data.stanza;
66 69
67 local session = full_sessions[stanza.attr.to]; 70 local session = full_sessions[stanza.attr.to];
68 if session then 71 if session and session.send(stanza) then
69 -- TODO fire post processing event
70 session.send(stanza);
71 return true; 72 return true;
72 else -- resource not online 73 else -- resource not online
73 return process_to_bare(jid_bare(stanza.attr.to), origin, stanza); 74 return process_to_bare(jid_bare(stanza.attr.to), origin, stanza);
74 end 75 end
75 end); 76 end);