comparison mod_carbons/mod_carbons.lua @ 618:267548522810

mod_carbons: Remove useless protection against loop that can't happen
author Kim Alvefur <zash@zash.se>
date Tue, 28 Feb 2012 14:33:35 +0100
parents 3ca933c9d8ff
children 2f11d2473afd
comparison
equal deleted inserted replaced
617:3ca933c9d8ff 618:267548522810
78 end); 78 end);
79 module:log("debug", "Message tagged private, ignoring"); 79 module:log("debug", "Message tagged private, ignoring");
80 return 80 return
81 end 81 end
82 82
83 if not stanza:get_child("forwarded", xmlns_forward) then 83 user_sessions = user_sessions and user_sessions.sessions;
84 user_sessions = user_sessions and user_sessions.sessions; 84 for resource, session in pairs(user_sessions) do
85 for resource, session in pairs(user_sessions) do 85 local full_jid = bare_jid .. "/" .. resource;
86 local full_jid = bare_jid .. "/" .. resource; 86 module:log("debug", "%s wants carbons: %s", session.full_jid, tostring(session.want_carbons));
87 module:log("debug", "%s wants carbons: %s", session.full_jid, tostring(session.want_carbons)); 87 if session.want_carbons then
88 if session.want_carbons then 88 if c2s then
89 if c2s then 89 module:log("debug", "Session is origin: %s", tostring(session == origin));
90 module:log("debug", "Session is origin: %s", tostring(session == origin)); 90 else
91 else 91 module:log("debug", "Session is in ignore list: %s", tostring(no_carbon_to[resource]));
92 module:log("debug", "Session is in ignore list: %s", tostring(no_carbon_to[resource])); 92 end
93 end 93 if (c2s and session ~= origin) or (not c2s and not no_carbon_to[resource]) then
94 if (c2s and session ~= origin) or (not c2s and not no_carbon_to[resource]) then 94 local msg = st.clone(stanza);
95 local msg = st.clone(stanza); 95 msg.attr.xmlns = msg.attr.xmlns or "jabber:client";
96 msg.attr.xmlns = msg.attr.xmlns or "jabber:client"; 96 local fwd = st.message{
97 local fwd = st.message{ 97 from = bare_jid,
98 from = bare_jid, 98 to = full_jid,
99 to = full_jid, 99 type = orig_type,
100 type = orig_type, 100 }
101 } 101 :tag(c2s and "sent" or "received", { xmlns = xmlns_carbons }):up()
102 :tag(c2s and "sent" or "received", { xmlns = xmlns_carbons }):up() 102 :tag("forwarded", { xmlns = xmlns_forward })
103 :tag("forwarded", { xmlns = xmlns_forward }) 103 :add_child(msg);
104 :add_child(msg); 104 module:log("debug", "Sending carbon");
105 module:log("debug", "Sending carbon"); 105 session.send(fwd);
106 session.send(fwd);
107 end
108 end 106 end
109 end 107 end
110 end 108 end
111 end 109 end
112 110