Diff

mod_pubsub_text_interface/mod_pubsub_text_interface.lua @ 3328:7d39ffd058d5

mod_pubsub_text_interface: Handle lack of `pubsub:get_last_item` in Prosody 0.10
author Kim Alvefur <zash@zash.se>
date Sun, 23 Sep 2018 16:43:03 +0200
parent 3293:f728c8c42860
child 3429:1f0c290bd28a
line wrap: on
line diff
--- a/mod_pubsub_text_interface/mod_pubsub_text_interface.lua	Sun Sep 23 14:20:06 2018 +0200
+++ b/mod_pubsub_text_interface/mod_pubsub_text_interface.lua	Sun Sep 23 16:43:03 2018 +0200
@@ -12,9 +12,10 @@
 - `help` - this help message
 - `list` - list available nodes
 - `subscribe node` - subscribe to a node
-- `unsubscribe node` - unsubscribe from a node
-- `last node` - send the last item (again)
-]];
+- `unsubscribe node` - unsubscribe from a node]];
+if pubsub.get_last_item then -- COMPAT not available in 0.10
+	help = help ..  "\n- `last node` - send the last item (again)"
+end
 
 module:hook("message/host", function (event)
 	local origin, stanza = event.origin, event.stanza;
@@ -48,7 +49,7 @@
 	elseif command == "unsubscribe" then
 		local ok, err = pubsub:remove_subscription(node_arg, from, jid.bare(from));
 		reply:body(ok and "OK" or err);
-	elseif command == "last" then
+	elseif command == "last" and pubsub.get_last_item then
 		local ok, item_id, item = pubsub:get_last_item(node_arg, from);
 		if not ok then
 			reply:body(item_id); -- err message