# HG changeset patch # User Kim Alvefur # Date 1510011575 -3600 # Node ID e2037634cdd91c1bda6b6fc208e8723063e286a0 # Parent b5266358624348a75ffc95f98994e43269397e88 mod_pubsub: Add a tail method (like util.cache) to archive_itemstore diff -r b52663586243 -r e2037634cdd9 plugins/mod_pubsub/pubsub.lib.lua --- 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;