Software /
code /
prosody
Comparison
plugins/mod_muc.lua @ 830:c0554caf90e6
MUC: Use util.stanza.clone instead of pre/deserialize for cloning stanzas
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 20 Feb 2009 02:23:21 +0500 |
parent | 828:97ea39b7bf90 |
child | 831:e2d2095705dc |
comparison
equal
deleted
inserted
replaced
829:b01fd698495e | 830:c0554caf90e6 |
---|---|
60 end | 60 end |
61 return stanza, 0; | 61 return stanza, 0; |
62 end | 62 end |
63 local presence_filters = {["http://jabber.org/protocol/muc"]=true;["http://jabber.org/protocol/muc#user"]=true}; | 63 local presence_filters = {["http://jabber.org/protocol/muc"]=true;["http://jabber.org/protocol/muc#user"]=true}; |
64 function get_filtered_presence(stanza) | 64 function get_filtered_presence(stanza) |
65 return filter_xmlns_from_stanza(st.deserialize(st.preserialize(stanza)), presence_filters); | 65 return filter_xmlns_from_stanza(st.clone(stanza), presence_filters); |
66 end | 66 end |
67 function getUsingPath(stanza, path, getText) | 67 function getUsingPath(stanza, path, getText) |
68 local tag = stanza; | 68 local tag = stanza; |
69 for _, name in ipairs(path) do | 69 for _, name in ipairs(path) do |
70 if type(tag) ~= 'table' then return; end | 70 if type(tag) ~= 'table' then return; end |
160 core_route_stanza(component, stanza); | 160 core_route_stanza(component, stanza); |
161 end | 161 end |
162 if not subject and body then -- add to history | 162 if not subject and body then -- add to history |
163 local history = rooms_info:get(room, 'history'); | 163 local history = rooms_info:get(room, 'history'); |
164 if not history then history = {}; rooms_info:set(room, 'history', history); end | 164 if not history then history = {}; rooms_info:set(room, 'history', history); end |
165 -- stanza = st.deserialize(st.preserialize(stanza)); | 165 -- stanza = st.clone(stanza); |
166 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 | 166 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 |
167 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) | 167 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) |
168 t_insert(history, st.preserialize(stanza)); | 168 t_insert(history, st.clone(st.preserialize(stanza))); |
169 while #history > history_length do t_remove(history, 1) end | 169 while #history > history_length do t_remove(history, 1) end |
170 end | 170 end |
171 end | 171 end |
172 end | 172 end |
173 function broadcast_message_stanza(room, stanza, historic) | 173 function broadcast_message_stanza(room, stanza, historic) |
180 end | 180 end |
181 end | 181 end |
182 if historic then -- add to history | 182 if historic then -- add to history |
183 local history = rooms_info:get(room, 'history'); | 183 local history = rooms_info:get(room, 'history'); |
184 if not history then history = {}; rooms_info:set(room, 'history', history); end | 184 if not history then history = {}; rooms_info:set(room, 'history', history); end |
185 -- stanza = st.deserialize(st.preserialize(stanza)); | 185 -- stanza = st.clone(stanza); |
186 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 | 186 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 |
187 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) | 187 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) |
188 t_insert(history, st.preserialize(stanza)); | 188 t_insert(history, st.clone(st.preserialize(stanza))); |
189 while #history > history_length do t_remove(history, 1) end | 189 while #history > history_length do t_remove(history, 1) end |
190 end | 190 end |
191 end | 191 end |
192 end | 192 end |
193 function broadcast_presence_stanza(room, stanza, code, nick) | 193 function broadcast_presence_stanza(room, stanza, code, nick) |