Diff

plugins/pubsub.lua @ 438:98dc1750584d 0.10.0

pubsub: Support for 'notify' in retract and purge operations This is a slight API change for :retract(), but should be backwards-compatible.
author Matthew Wild <mwild1@gmail.com>
date Mon, 06 Dec 2021 09:09:50 +0000
parent 437:2762abec4c63
child 468:fae5ae0ddb84
line wrap: on
line diff
--- a/plugins/pubsub.lua	Mon Dec 06 09:03:39 2021 +0000
+++ b/plugins/pubsub.lua	Mon Dec 06 09:09:50 2021 +0000
@@ -256,15 +256,39 @@
 	, callback);
 end
 
-function pubsub_node:retract(id, callback)
-	self.stream:send_iq(pubsub_iq("set", self.service, nil, "retract", self.node, nil, id)
-	, callback);
+function pubsub_node:retract(id, notify, callback)
+	if type(notify) == "function" then -- COMPAT w/ older versions before 'notify' was added
+		notify, callback = false, notify;
+	end
+	self.stream:send_iq(
+		pubsub_iq(
+			"set",
+			self.service,
+			nil,
+			"retract",
+			self.node,
+			nil,
+			id,
+			{ notify = notify and "1" or nil }
+		),
+		callback
+	);
 end
 
 function pubsub_node:purge(notify, callback)
-	assert(not notify, "Not implemented yet.");
-	self.stream:send_iq(pubsub_iq("set", self.service, xmlns_pubsub_owner, "purge", self.node)
-	, callback);
+	self.stream:send_iq(
+		pubsub_iq(
+			"set",
+			self.service,
+			xmlns_pubsub_owner,
+			"purge",
+			self.node,
+			nil,
+			nil,
+			{ notify = notify and "1" or nil }
+		),
+		callback
+	);
 end
 
 function pubsub_node:delete(redirect_uri, callback)