Comparison

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
comparison
equal deleted inserted replaced
437:2762abec4c63 438:98dc1750584d
254 function pubsub_node:item(id, callback) 254 function pubsub_node:item(id, callback)
255 self.stream:send_iq(pubsub_iq("get", self.service, nil, "items", self.node, nil, id) 255 self.stream:send_iq(pubsub_iq("get", self.service, nil, "items", self.node, nil, id)
256 , callback); 256 , callback);
257 end 257 end
258 258
259 function pubsub_node:retract(id, callback) 259 function pubsub_node:retract(id, notify, callback)
260 self.stream:send_iq(pubsub_iq("set", self.service, nil, "retract", self.node, nil, id) 260 if type(notify) == "function" then -- COMPAT w/ older versions before 'notify' was added
261 , callback); 261 notify, callback = false, notify;
262 end
263 self.stream:send_iq(
264 pubsub_iq(
265 "set",
266 self.service,
267 nil,
268 "retract",
269 self.node,
270 nil,
271 id,
272 { notify = notify and "1" or nil }
273 ),
274 callback
275 );
262 end 276 end
263 277
264 function pubsub_node:purge(notify, callback) 278 function pubsub_node:purge(notify, callback)
265 assert(not notify, "Not implemented yet."); 279 self.stream:send_iq(
266 self.stream:send_iq(pubsub_iq("set", self.service, xmlns_pubsub_owner, "purge", self.node) 280 pubsub_iq(
267 , callback); 281 "set",
282 self.service,
283 xmlns_pubsub_owner,
284 "purge",
285 self.node,
286 nil,
287 nil,
288 { notify = notify and "1" or nil }
289 ),
290 callback
291 );
268 end 292 end
269 293
270 function pubsub_node:delete(redirect_uri, callback) 294 function pubsub_node:delete(redirect_uri, callback)
271 assert(not redirect_uri, "Not implemented yet."); 295 assert(not redirect_uri, "Not implemented yet.");
272 self.stream:send_iq(pubsub_iq("set", self.service, xmlns_pubsub_owner, "delete", self.node) 296 self.stream:send_iq(pubsub_iq("set", self.service, xmlns_pubsub_owner, "delete", self.node)