From fb51acd8426dfa359c0ea512c7470d6332ade9d1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 7 Nov 2017 00:40:52 +0100 Subject: util.pubsub: Add method for retreiving the last item (useful for sending on subscribe) --- util/pubsub.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/pubsub.lua b/util/pubsub.lua index 575153b8..2f42809e 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -351,6 +351,15 @@ function service:get_items(node, actor, id) end end +function service:get_last_item(node, actor) + -- Access checking + if not self:may(node, actor, "get_items") then + return false, "forbidden"; + end + -- + return true, self.data[node]:tail(); +end + function service:get_nodes(actor) -- Access checking if not self:may(nil, actor, "get_nodes") then -- cgit v1.2.3