Mercurial > prosody-modules
comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 5742:645de410dbca
mod_storage_xmlarchive: Support using requested archive-id
However diverging from the date-prefixed format means it will need to
look through the whole archive to find a particular ID.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 29 Nov 2023 11:14:21 +0100 |
parents | 5232d12eb74d |
children |
comparison
equal
deleted
inserted
replaced
5741:5232d12eb74d | 5742:645de410dbca |
---|---|
32 | 32 |
33 local is_stanza = st.is_stanza or function (s) | 33 local is_stanza = st.is_stanza or function (s) |
34 return getmetatable(s) == st.stanza_mt; | 34 return getmetatable(s) == st.stanza_mt; |
35 end | 35 end |
36 | 36 |
37 function archive:append(username, _, data, when, with) | 37 function archive:append(username, id, data, when, with) |
38 if not is_stanza(data) then | 38 if not is_stanza(data) then |
39 module:log("error", "Attempt to store non-stanza object, traceback: %s", debug.traceback()); | 39 module:log("error", "Attempt to store non-stanza object, traceback: %s", debug.traceback()); |
40 return nil, "unsupported-datatype"; | 40 return nil, "unsupported-datatype"; |
41 end | 41 end |
42 | 42 |
55 -- If the day-file is missing then we need to add it to the list of days | 55 -- If the day-file is missing then we need to add it to the list of days |
56 local first_of_day = not lfs.attributes(dm.getpath(username .. "@" .. day, self.host, self.store, "list")); | 56 local first_of_day = not lfs.attributes(dm.getpath(username .. "@" .. day, self.host, self.store, "list")); |
57 | 57 |
58 local offset = ok and err or 0; | 58 local offset = ok and err or 0; |
59 | 59 |
60 local id = day .. "-" .. hmac_sha256(username.."@"..day.."+"..offset, data, true):sub(-16); | 60 id = id or day .. "-" .. hmac_sha256(username.."@"..day.."+"..offset, data, true):sub(-16); |
61 ok, err = dm.list_append(username.."@"..day, self.host, self.store, | 61 ok, err = dm.list_append(username.."@"..day, self.host, self.store, |
62 { id = id, when = dt.datetime(when), with = with, offset = offset, length = #data }); | 62 { id = id, when = dt.datetime(when), with = with, offset = offset, length = #data }); |
63 if ok and first_of_day then | 63 if ok and first_of_day then |
64 ok, err = dm.list_append(username, self.host, self.store, day); | 64 ok, err = dm.list_append(username, self.host, self.store, day); |
65 end | 65 end |