From 3b0d35ed9ac528e73b0539c33304beb83a2962d5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 7 Nov 2017 00:39:35 +0100 Subject: mod_pubsub: Add a tail method (like util.cache) to archive_itemstore --- plugins/mod_pubsub/pubsub.lib.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins/mod_pubsub') diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index c44801dd..ae99167f 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -490,6 +490,13 @@ local function archive_itemstore(archive, config, user, node) 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; -- cgit v1.2.3