Mercurial > prosody-modules
comparison mod_mam/mod_mam.lua @ 1685:cd87a2eba8f2
mod_mam: Reverse the order of reversed queries back to chronological order
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 03 May 2015 13:34:23 +0200 |
| parents | 838150167871 |
| children | 55bc42c1d8c5 |
comparison
equal
deleted
inserted
replaced
| 1684:838150167871 | 1685:cd87a2eba8f2 |
|---|---|
| 137 local total = err; | 137 local total = err; |
| 138 | 138 |
| 139 origin.send(st.reply(stanza)) | 139 origin.send(st.reply(stanza)) |
| 140 local msg_reply_attr = { to = stanza.attr.from, from = stanza.attr.to }; | 140 local msg_reply_attr = { to = stanza.attr.from, from = stanza.attr.to }; |
| 141 | 141 |
| 142 local results = {}; | |
| 143 | |
| 142 -- Wrap it in stuff and deliver | 144 -- Wrap it in stuff and deliver |
| 143 local first, last; | 145 local first, last; |
| 144 local count = 0; | 146 local count = 0; |
| 145 local complete = "true"; | 147 local complete = "true"; |
| 146 for id, item, when in data do | 148 for id, item, when in data do |
| 161 fwd_st:add_child(item); | 163 fwd_st:add_child(item); |
| 162 | 164 |
| 163 if not first then first = id; end | 165 if not first then first = id; end |
| 164 last = id; | 166 last = id; |
| 165 | 167 |
| 166 origin.send(fwd_st); | 168 if reverse then |
| 167 end | 169 results[count] = fwd_st; |
| 170 else | |
| 171 origin.send(fwd_st); | |
| 172 end | |
| 173 end | |
| 174 if reverse then | |
| 175 for i = #results, 1, -1 do | |
| 176 origin.send(results[i]); | |
| 177 end | |
| 178 end | |
| 179 | |
| 168 -- That's all folks! | 180 -- That's all folks! |
| 169 module:log("debug", "Archive query %s completed", tostring(qid)); | 181 module:log("debug", "Archive query %s completed", tostring(qid)); |
| 170 | 182 |
| 171 if reverse then first, last = last, first; end | 183 if reverse then first, last = last, first; end |
| 172 origin.send(st.message(msg_reply_attr) | 184 origin.send(st.message(msg_reply_attr) |
