Changeset

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
parents 8374:b52663586243
children 8376:eb6a9c314c86
files plugins/mod_pubsub/pubsub.lib.lua
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
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;