pubsub: Support for 'notify' in retract and purge operations 0.10.0

Mon, 06 Dec 2021 09:09:50 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 06 Dec 2021 09:09:50 +0000
changeset 438
98dc1750584d
parent 437
2762abec4c63
child 451
a0c55329c38d

pubsub: Support for 'notify' in retract and purge operations

This is a slight API change for :retract(), but should be backwards-compatible.

plugins/pubsub.lua file | annotate | diff | comparison | revisions
--- 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)

mercurial