# HG changeset patch # User Waqas Hussain # Date 1235078601 -18000 # Node ID c0554caf90e616769bd19c49f162be2ed07e51af # Parent b01fd698495e8061b86de3d5cd06b2c8cd6b6955 MUC: Use util.stanza.clone instead of pre/deserialize for cloning stanzas diff -r b01fd698495e -r c0554caf90e6 plugins/mod_muc.lua --- a/plugins/mod_muc.lua Fri Feb 20 02:18:07 2009 +0500 +++ b/plugins/mod_muc.lua Fri Feb 20 02:23:21 2009 +0500 @@ -62,7 +62,7 @@ end local presence_filters = {["http://jabber.org/protocol/muc"]=true;["http://jabber.org/protocol/muc#user"]=true}; function get_filtered_presence(stanza) - return filter_xmlns_from_stanza(st.deserialize(st.preserialize(stanza)), presence_filters); + return filter_xmlns_from_stanza(st.clone(stanza), presence_filters); end function getUsingPath(stanza, path, getText) local tag = stanza; @@ -162,10 +162,10 @@ if not subject and body then -- add to history local history = rooms_info:get(room, 'history'); if not history then history = {}; rooms_info:set(room, 'history', history); end - -- stanza = st.deserialize(st.preserialize(stanza)); + -- stanza = st.clone(stanza); stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) - t_insert(history, st.preserialize(stanza)); + t_insert(history, st.clone(st.preserialize(stanza))); while #history > history_length do t_remove(history, 1) end end end @@ -182,10 +182,10 @@ if historic then -- add to history local history = rooms_info:get(room, 'history'); if not history then history = {}; rooms_info:set(room, 'history', history); end - -- stanza = st.deserialize(st.preserialize(stanza)); + -- stanza = st.clone(stanza); stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = datetime.datetime()}):up(); -- XEP-0203 stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) - t_insert(history, st.preserialize(stanza)); + t_insert(history, st.clone(st.preserialize(stanza))); while #history > history_length do t_remove(history, 1) end end end