Software /
code /
prosody
Diff
plugins/mod_pubsub/pubsub.lib.lua @ 8375:e2037634cdd9
mod_pubsub: Add a tail method (like util.cache) to archive_itemstore
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 07 Nov 2017 00:39:35 +0100 |
parent | 8374:b52663586243 |
child | 8399:07443fe9df5b |
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua Mon Nov 06 21:03:30 2017 +0100 +++ b/plugins/mod_pubsub/pubsub.lib.lua Tue Nov 07 00:39:35 2017 +0100 @@ -490,6 +490,13 @@ function get_set:clear() -- luacheck: ignore 212/self return archive:delete(user); end + function get_set:tail() + -- This should conveniently return the last item + local item = self:get(nil); + if item then + return item.attr.id, item; + end + end return setmetatable(get_set, archive); end _M.archive_itemstore = archive_itemstore;