Comparison

plugins/muc/muc.lib.lua @ 6142:a6e526c00e6e

plugins/muc/muc.lib: Have timestamp as seconds since epoch inside of history
author daurnimator <quae@daurnimator.com>
date Thu, 27 Mar 2014 18:10:34 -0400
parent 6141:bf6de8ef66c2
child 6143:82b3a2155a55
comparison
equal deleted inserted replaced
6141:bf6de8ef66c2 6142:a6e526c00e6e
129 local room = event.room 129 local room = event.room
130 local history = room._data['history']; 130 local history = room._data['history'];
131 if not history then history = {}; room._data['history'] = history; end 131 if not history then history = {}; room._data['history'] = history; end
132 local stanza = st.clone(event.stanza); 132 local stanza = st.clone(event.stanza);
133 stanza.attr.to = ""; 133 stanza.attr.to = "";
134 local stamp = datetime.datetime(); 134 local ts = gettime();
135 local stamp = datetime.datetime(ts);
135 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp}):up(); -- XEP-0203 136 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp}):up(); -- XEP-0203
136 stanza:tag("x", {xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated) 137 stanza:tag("x", {xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
137 local entry = { stanza = stanza, stamp = stamp }; 138 local entry = { stanza = stanza, timestamp = ts };
138 t_insert(history, entry); 139 t_insert(history, entry);
139 while #history > room:get_historylength() do t_remove(history, 1) end 140 while #history > room:get_historylength() do t_remove(history, 1) end
140 end 141 end
141 end) 142 end)
142 143
218 entry.chars = #tostring(entry.stanza); 219 entry.chars = #tostring(entry.stanza);
219 end 220 end
220 charcount = charcount + entry.chars + #to; 221 charcount = charcount + entry.chars + #to;
221 if charcount > maxchars then break; end 222 if charcount > maxchars then break; end
222 end 223 end
223 if since and since > entry.stamp then break; end 224 if since and since > entry.timestamp then break; end
224 if n + 1 > maxstanzas then break; end 225 if n + 1 > maxstanzas then break; end
225 n = n + 1; 226 n = n + 1;
226 end 227 end
227 228
228 local i = history_len-n+1 229 local i = history_len-n+1