# HG changeset patch # User Kim Alvefur # Date 1659487675 -7200 # Node ID a0c55329c38d8961655758f5dc1647ec1b4dad00 # Parent e72deac76e0e169263727615cd0bf9361000c29c# Parent 98dc1750584d8011c3bfb6d2b252c492edbb2986 Merge with MattJ diff -r e72deac76e0e -r a0c55329c38d plugins/pubsub.lua --- a/plugins/pubsub.lua Sat Feb 19 15:57:24 2022 +0100 +++ b/plugins/pubsub.lua Wed Aug 03 02:47:55 2022 +0200 @@ -58,11 +58,19 @@ -- Helper function for iq+pubsub tags -local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id) +local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id, op_attr_extra) local st = verse.iq{ type = iq_type or "get", to = to } :tag("pubsub", { xmlns = ns or xmlns_pubsub }) -- ns would be ..#owner - if op then st:tag(op, { node = node, jid = jid }); end - if item_id then st:tag("item", { id = item_id ~= true and item_id or nil }); end + local op_attr = { node = node, jid = jid }; + if op_attr_extra then + for k, v in pairs(op_attr_extra) do + op_attr[k] = v; + end + end + if op then st:tag(op, op_attr); end + if item_id then + st:tag("item", { id = item_id ~= true and item_id or nil }); + end return st; end @@ -248,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)