Software / code / prosody
Comparison
plugins/mod_storage_internal.lua @ 11275:b8fada57faf0
mod_storage_internal: Add support for full ID range query
Based on the mod_storage_memory implementation
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 12 Jan 2021 17:00:27 +0100 |
| parent | 10926:c55bd98a54f8 |
| child | 11278:c3907f05bed4 |
comparison
equal
deleted
inserted
replaced
| 11274:ecbfde402364 | 11275:b8fada57faf0 |
|---|---|
| 50 | 50 |
| 51 archive.caps = { | 51 archive.caps = { |
| 52 total = true; | 52 total = true; |
| 53 quota = archive_item_limit; | 53 quota = archive_item_limit; |
| 54 truncate = true; | 54 truncate = true; |
| 55 full_id_range = true; | |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 function archive:append(username, key, value, when, with) | 58 function archive:append(username, key, value, when, with) |
| 58 when = when or now(); | 59 when = when or now(); |
| 59 if not st.is_stanza(value) then | 60 if not st.is_stanza(value) then |
| 176 end | 177 end |
| 177 if not found then | 178 if not found then |
| 178 return nil, "item-not-found"; | 179 return nil, "item-not-found"; |
| 179 end | 180 end |
| 180 end | 181 end |
| 181 elseif query.before then | 182 last_key = query.after; |
| 182 last_key = query.before; | |
| 183 elseif query.after then | 183 elseif query.after then |
| 184 local found = false; | 184 local found = false; |
| 185 for j = 1, #items do | 185 for j = 1, #items do |
| 186 if (items[j].key or tostring(j)) == query.after then | 186 if (items[j].key or tostring(j)) == query.after then |
| 187 found = true; | 187 found = true; |
| 190 end | 190 end |
| 191 end | 191 end |
| 192 if not found then | 192 if not found then |
| 193 return nil, "item-not-found"; | 193 return nil, "item-not-found"; |
| 194 end | 194 end |
| 195 last_key = query.before; | |
| 196 elseif query.before then | |
| 197 last_key = query.before; | |
| 195 end | 198 end |
| 196 if query.limit and #items - i > query.limit then | 199 if query.limit and #items - i > query.limit then |
| 197 items[i+query.limit+1] = nil; | 200 items[i+query.limit+1] = nil; |
| 198 end | 201 end |
| 199 end | 202 end |