mod_pubsub: Add a tail method (like util.cache) to archive_itemstore

This commit is contained in:
Kim Alvefur 2017-11-07 00:39:35 +01:00
parent 5b91ff0bab
commit 3b0d35ed9a

View file

@ -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;