plugins/pubsub.lua

changeset 437
2762abec4c63
parent 395
e86144a4eaa1
child 438
98dc1750584d
equal deleted inserted replaced
436:a9be85b2da17 437:2762abec4c63
56 return setmetatable({ stream = self.stream, service = service }, pubsub_service_mt) 56 return setmetatable({ stream = self.stream, service = service }, pubsub_service_mt)
57 end 57 end
58 58
59 -- Helper function for iq+pubsub tags 59 -- Helper function for iq+pubsub tags
60 60
61 local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id) 61 local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id, op_attr_extra)
62 local st = verse.iq{ type = iq_type or "get", to = to } 62 local st = verse.iq{ type = iq_type or "get", to = to }
63 :tag("pubsub", { xmlns = ns or xmlns_pubsub }) -- ns would be ..#owner 63 :tag("pubsub", { xmlns = ns or xmlns_pubsub }) -- ns would be ..#owner
64 if op then st:tag(op, { node = node, jid = jid }); end 64 local op_attr = { node = node, jid = jid };
65 if item_id then st:tag("item", { id = item_id ~= true and item_id or nil }); end 65 if op_attr_extra then
66 for k, v in pairs(op_attr_extra) do
67 op_attr[k] = v;
68 end
69 end
70 if op then st:tag(op, op_attr); end
71 if item_id then
72 st:tag("item", { id = item_id ~= true and item_id or nil });
73 end
66 return st; 74 return st;
67 end 75 end
68 76
69 -- http://xmpp.org/extensions/xep-0060.html#entity-subscriptions 77 -- http://xmpp.org/extensions/xep-0060.html#entity-subscriptions
70 function pubsub_service:subscriptions(callback) 78 function pubsub_service:subscriptions(callback)

mercurial