Comparison

util/pubsub.lua @ 8376:eb6a9c314c86

util.pubsub: Add method for retreiving the last item (useful for sending on subscribe)
author Kim Alvefur <zash@zash.se>
date Tue, 07 Nov 2017 00:40:52 +0100
parent 8343:5df2f240173b
child 8382:e5d00bf4a4d5
comparison
equal deleted inserted replaced
8375:e2037634cdd9 8376:eb6a9c314c86
347 data[#data+1] = key; 347 data[#data+1] = key;
348 data[key] = value; 348 data[key] = value;
349 end 349 end
350 return true, data; 350 return true, data;
351 end 351 end
352 end
353
354 function service:get_last_item(node, actor)
355 -- Access checking
356 if not self:may(node, actor, "get_items") then
357 return false, "forbidden";
358 end
359 --
360 return true, self.data[node]:tail();
352 end 361 end
353 362
354 function service:get_nodes(actor) 363 function service:get_nodes(actor)
355 -- Access checking 364 -- Access checking
356 if not self:may(nil, actor, "get_nodes") then 365 if not self:may(nil, actor, "get_nodes") then