Skip to content

Commit

Permalink
mam.lib: resolve bug when asking the last x number of messages,
Browse files Browse the repository at this point in the history
when querying for conversations with a specific jid. (Fixes #45)
  • Loading branch information
maranda committed Nov 29, 2013
1 parent 5ee4395 commit 8a34eb6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion metronome.release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.4
3.1.5
15 changes: 13 additions & 2 deletions plugins/mam/mam.lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,20 @@ local function generate_stanzas(store, start, fin, with, max, after, before, qid
if before then
if before == true then
to_process = {};
local _logs_with;
if with then
_logs_with = {};
for i, e in ipairs(logs) do
if e.bare_to == with or e.bare_from == with then
_logs_with[#_logs_with + 1] = e;
end
end
end

-- we clone the table from the end backward count
local total = #logs;
for i = (max > total and 1) or total - max, total do to_process[#to_process +1] = logs[i]; end
local total = (_logs_with and #_logs_with) or #logs;
local _logs = (_logs_with and _logs_with) or logs;
for i = (max > total and 1) or total - max, total do to_process[#to_process + 1] = _logs[i]; end
_entries_count = total;
else
entry_index = get_index(logs, before);
Expand Down

0 comments on commit 8a34eb6

Please sign in to comment.