comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 2663:6e8c3fc48237

mod_storage_xmlarchive: Use the dates method in more places
author Kim Alvefur <zash@zash.se>
date Sat, 01 Apr 2017 17:39:39 +0200
parents 71ce798c86cc
children 101a2a0b8b33
comparison
equal deleted inserted replaced
2662:2d5e0e2938d1 2663:6e8c3fc48237
89 end 89 end
90 90
91 local stream_session = { notopen = true }; 91 local stream_session = { notopen = true };
92 local stream_callbacks = { handlestanza = cb, stream_ns = "jabber:client", default_ns = "jabber:client" }; 92 local stream_callbacks = { handlestanza = cb, stream_ns = "jabber:client", default_ns = "jabber:client" };
93 local stream = new_stream(stream_session, stream_callbacks); 93 local stream = new_stream(stream_session, stream_callbacks);
94 local dates = dm.list_load(username, module.host, self.store) or empty; 94 local dates = self:dates() or empty;
95 local function reset_stream() 95 local function reset_stream()
96 stream:reset(); 96 stream:reset();
97 stream_session.notopen = true; 97 stream_session.notopen = true;
98 stream:feed(st.stanza("stream", { xmlns = "jabber:client" }):top_tag()); 98 stream:feed(st.stanza("stream", { xmlns = "jabber:client" }):top_tag());
99 stream_session.notopen = nil; 99 stream_session.notopen = nil;
242 if query.with or query.start or query.after then 242 if query.with or query.start or query.after then
243 return nil, "not-implemented"; -- Only trimming the oldest messages 243 return nil, "not-implemented"; -- Only trimming the oldest messages
244 end 244 end
245 local before = query.before or query["end"] or "9999-12-31"; 245 local before = query.before or query["end"] or "9999-12-31";
246 if type(before) == "number" then before = dt.date(before); else before = before:sub(1, 10); end 246 if type(before) == "number" then before = dt.date(before); else before = before:sub(1, 10); end
247 local dates, err = dm.list_load(username, module.host, self.store); 247 local dates, err = self:dates(username);
248 if not dates or next(dates) == nil then 248 if not dates or next(dates) == nil then
249 if not err then return true end -- already empty 249 if not err then return true end -- already empty
250 return dates, err; 250 return dates, err;
251 end 251 end
252 if dates[1] > before then return true; end -- Nothing to delete 252 if dates[1] > before then return true; end -- Nothing to delete