Mercurial > prosody-hg
comparison plugins/mod_muc_mam.lua @ 8783:79133eca0656
mod_muc_mam: Tweak calculation of max history to retrieve
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 28 Apr 2018 00:44:28 +0200 |
| parents | ced09d7d7c96 |
| children | 64b78e3deb96 |
comparison
equal
deleted
inserted
replaced
| 8782:daa518a22c34 | 8783:79133eca0656 |
|---|---|
| 239 | 239 |
| 240 module:hook("muc-get-history", function (event) | 240 module:hook("muc-get-history", function (event) |
| 241 local room = event.room; | 241 local room = event.room; |
| 242 if not archiving_enabled(room) then return end | 242 if not archiving_enabled(room) then return end |
| 243 local room_jid = room.jid; | 243 local room_jid = room.jid; |
| 244 local maxstanzas = event.maxstanzas or math.huge; | 244 local maxstanzas = event.maxstanzas; |
| 245 local maxchars = event.maxchars; | 245 local maxchars = event.maxchars; |
| 246 local since = event.since; | 246 local since = event.since; |
| 247 local to = event.to; | 247 local to = event.to; |
| 248 | 248 |
| 249 if not maxstanzas or maxstanzas > get_historylength(room) then | |
| 250 maxstanzas = get_historylength(room); | |
| 251 end | |
| 252 | |
| 249 -- Load all the data! | 253 -- Load all the data! |
| 250 local query = { | 254 local query = { |
| 251 limit = math.min(maxstanzas, get_historylength(room)); | 255 limit = maxstanzas; |
| 252 start = since; | 256 start = since; |
| 253 reverse = true; | 257 reverse = true; |
| 254 with = "message<groupchat"; | 258 with = "message<groupchat"; |
| 255 } | 259 } |
| 256 local data, err = archive:find(jid_split(room_jid), query); | 260 local data, err = archive:find(jid_split(room_jid), query); |
