Comparison

plugins/mod_muc_mam.lua @ 12859:cd738fb8c754 0.12

mod_muc_mam: Copy "include total" behavior from mod_mam Not sure why this was missing from MUC MAM, it already had some of the code for dealing with it.
author Kim Alvefur <zash@zash.se>
date Sat, 21 Jan 2023 17:14:55 +0100
parent 12858:71dc48a89e5a
child 12861:57e86d537ffe
child 13267:7ae000fc8c07
comparison
equal deleted inserted replaced
12858:71dc48a89e5a 12859:cd738fb8c754
65 module:log("error", "Attempt to open archive storage returned null driver"); 65 module:log("error", "Attempt to open archive storage returned null driver");
66 end 66 end
67 module:log("info", "See https://prosody.im/doc/storage and https://prosody.im/doc/archiving for more information"); 67 module:log("info", "See https://prosody.im/doc/storage and https://prosody.im/doc/archiving for more information");
68 return false; 68 return false;
69 end 69 end
70 local use_total = module:get_option_boolean("muc_log_include_total", true);
70 71
71 local function archiving_enabled(room) 72 local function archiving_enabled(room)
72 if log_all_rooms then 73 if log_all_rooms then
73 module:log("debug", "Archiving all rooms"); 74 module:log("debug", "Archiving all rooms");
74 return true; 75 return true;
201 with = "message<groupchat"; 202 with = "message<groupchat";
202 limit = qmax + 1; 203 limit = qmax + 1;
203 before = before; after = after; 204 before = before; after = after;
204 ids = qids; 205 ids = qids;
205 reverse = reverse; 206 reverse = reverse;
206 total = qmax == 0; 207 total = use_total or qmax == 0;
207 }); 208 });
208 209
209 if not data then 210 if not data then
210 module:log("debug", "Archive query id=%s failed: %s", qid or stanza.attr.id, err); 211 module:log("debug", "Archive query id=%s failed: %s", qid or stanza.attr.id, err);
211 if err == "item-not-found" then 212 if err == "item-not-found" then
562 cleanup_done(); 563 cleanup_done();
563 end); 564 end);
564 565
565 else 566 else
566 module:log("debug", "Archive expiry disabled"); 567 module:log("debug", "Archive expiry disabled");
567 end 568 -- Don't ask the backend to count the potentially unbounded number of items,
569 -- it'll get slow.
570 use_total = module:get_option_boolean("mam_include_total", false);
571 end