Annotate

plugins/pubsub.lua @ 333:36e9d5a2ae79

plugins.pubsub: Implement retract, purge and delete operations
author Kim Alvefur <zash@zash.se>
date Sun, 10 Feb 2013 18:16:25 +0100
parent 332:6ecf44918156
child 337:8dce8240a77c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
250
a5ac643a7fd6 added local verse var to all plugins
mva <mva@mva.name>
parents: 248
diff changeset
1 local verse = require "verse";
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local jid_bare = require "util.jid".bare;
250
a5ac643a7fd6 added local verse var to all plugins
mva <mva@mva.name>
parents: 248
diff changeset
3
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
4 local t_insert = table.insert;
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
7 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors";
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 local pubsub = {};
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 local pubsub_mt = { __index = pubsub };
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 function verse.plugins.pubsub(stream)
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 stream.pubsub = setmetatable({ stream = stream }, pubsub_mt);
159
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
16 stream:hook("message", function (message)
283
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
17 local m_from = message.attr.from;
193
fa6e1e65cb3c plugins.pubsub: Fix to use :childtags() for iterating through items in a pubsub notification (:matching_tags() was removed from Prosody)
Matthew Wild <mwild1@gmail.com>
parents: 165
diff changeset
18 for pubsub_event in message:childtags("event", xmlns_pubsub_event) do
159
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
19 local items = pubsub_event:get_child("items");
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
20 if items then
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
21 local node = items.attr.node;
193
fa6e1e65cb3c plugins.pubsub: Fix to use :childtags() for iterating through items in a pubsub notification (:matching_tags() was removed from Prosody)
Matthew Wild <mwild1@gmail.com>
parents: 165
diff changeset
22 for item in items:childtags("item") do
159
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
23 stream:event("pubsub/event", {
283
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
24 from = m_from;
159
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
25 node = node;
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
26 item = item;
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
27 });
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
28 end
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
29 end
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
30 end
88cc513e81c8 plugins.pubsub: Fire pubsub/event on incoming pubsub notifications
Matthew Wild <mwild1@gmail.com>
parents: 154
diff changeset
31 end);
165
8c67ea868c06 plugins.pubsub: Return true to indicate success loading
Matthew Wild <mwild1@gmail.com>
parents: 159
diff changeset
32 return true;
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 end
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34
248
c4b55b0dc6ba plugins.pubsub: Make the old functions wrap the new.
Kim Alvefur <zash@zash.se>
parents: 222
diff changeset
35 -- COMPAT
221
efb4f60ba36e plugins.pubsub: implement node creation
Kim Alvefur <zash@zash.se>
parents: 193
diff changeset
36 function pubsub:create(server, node, callback)
265
2a2326a8f9e8 plugins.pubsub: Fix to use correct method in backwards-compatibility code
Matthew Wild <mwild1@gmail.com>
parents: 264
diff changeset
37 return self:service(server):node(node):create(nil, callback);
221
efb4f60ba36e plugins.pubsub: implement node creation
Kim Alvefur <zash@zash.se>
parents: 193
diff changeset
38 end
efb4f60ba36e plugins.pubsub: implement node creation
Kim Alvefur <zash@zash.se>
parents: 193
diff changeset
39
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 function pubsub:subscribe(server, node, jid, callback)
265
2a2326a8f9e8 plugins.pubsub: Fix to use correct method in backwards-compatibility code
Matthew Wild <mwild1@gmail.com>
parents: 264
diff changeset
41 return self:service(server):node(node):subscribe(jid, nil, callback);
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 end
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 function pubsub:publish(server, node, id, item, callback)
265
2a2326a8f9e8 plugins.pubsub: Fix to use correct method in backwards-compatibility code
Matthew Wild <mwild1@gmail.com>
parents: 264
diff changeset
45 return self:service(server):node(node):publish(id, nil, item, callback);
154
a4dc96890729 plugins.pubsub, squishy: New pubsub plugin (basic)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 end
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
47
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
48 --------------------------------------------------------------------------
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
49 ---------------------New and improved PubSub interface--------------------
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
50 --------------------------------------------------------------------------
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
51
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
52 local pubsub_service = {};
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
53 local pubsub_service_mt = { __index = pubsub_service };
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
54
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
55 -- TODO should the property be named 'jid' instead?
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
56 function pubsub:service(service)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
57 return setmetatable({ stream = self.stream, service = service }, pubsub_service_mt)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
58 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
59
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
60 -- Helper function for iq+pubsub tags
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
61
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
62 local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
63 local st = verse.iq{ type = iq_type or "get", to = to }
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
64 :tag("pubsub", { xmlns = ns or xmlns_pubsub }) -- ns would be ..#owner
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
65 if op then st:tag(op, { node = node, jid = jid }); end
264
ffb27e62a11e plugins.pubsub: Fix typo
Kim Alvefur <zash@zash.se>
parents: 263
diff changeset
66 if item_id then st:tag("item", { id = item_id ~= true and item_id or nil }); end
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
67 return st;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
68 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
69
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
70 -- http://xmpp.org/extensions/xep-0060.html#entity-subscriptions
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
71 function pubsub_service:subscriptions(callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
72 self.stream:send_iq(pubsub_iq(nil, self.service, nil, "subscriptions")
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
73 , callback and function (result)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
74 if result.attr.type == "result" then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
75 local ps = result:get_child("pubsub", xmlns_pubsub);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
76 local subs = ps and ps:get_child("subscriptions");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
77 local nodes = {};
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
78 if subs then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
79 for sub in subs:childtags("subscription") do
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
80 local node = self:node(sub.attr.node)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
81 node.subscription = sub;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
82 t_insert(nodes, node);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
83 -- FIXME Good enough?
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
84 -- Or how about:
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
85 -- nodes[node] = sub;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
86 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
87 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
88 callback(nodes);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
89 else
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
90 callback(false, result:get_error());
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
91 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
92 end or nil);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
93 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
94
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
95 -- http://xmpp.org/extensions/xep-0060.html#entity-affiliations
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
96 function pubsub_service:affiliations(callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
97 self.stream:send_iq(pubsub_iq(nil, self.service, nil, "affiliations")
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
98 , callback and function (result)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
99 if result.attr.type == "result" then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
100 local ps = result:get_child("pubsub", xmlns_pubsub);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
101 local affils = ps and ps:get_child("affiliations") or {};
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
102 local nodes = {};
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
103 if affils then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
104 for affil in affils:childtags("affiliation") do
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
105 local node = self:node(affil.attr.node)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
106 node.affiliation = affil;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
107 t_insert(nodes, node);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
108 -- nodes[node] = affil;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
109 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
110 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
111 callback(nodes);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
112 else
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
113 callback(false, result:get_error());
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
114 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
115 end or nil);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
116 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
117
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
118 -- TODO Listing nodes? It's done with standard disco#items, but should
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
119 -- we have a wrapper here? If so, it could wrap items in pubsub_node objects
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
120
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
121 --[[
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
122 function pubsub_service:nodes(callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
123 self.stream:disco_items(...)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
124 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
125 --]]
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
126
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
127 local pubsub_node = {};
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
128 local pubsub_node_mt = { __index = pubsub_node };
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
129
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
130 function pubsub_service:node(node)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
131 return setmetatable({ stream = self.stream, service = self.service, node = node }, pubsub_node_mt)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
132 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
133
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
134 function pubsub_mt:__call(service, node)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
135 local s = self:service(service);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
136 return node and s:node(node) or s;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
137 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
138
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
139 function pubsub_node:hook(callback, prio)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
140 local function hook(event)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
141 -- FIXME service == nil would mean anyone,
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
142 -- publishing would be go to your bare jid.
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
143 -- So if you're only interestied in your own
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
144 -- events, hook your own bare jid.
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
145 if (not event.service or event.from == self.service) and event.node == self.node then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
146 return callback(event)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
147 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
148 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
149 self.stream:hook("pubsub/event", hook, prio);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
150 return hook;
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
151 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
152
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
153 function pubsub_node:unhook(callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
154 self.stream:unhook("pubsub/event", callback);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
155 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
156
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
157 function pubsub_node:create(config, callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
158 if config ~= nil then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
159 error("Not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
160 else
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
161 self.stream:send_iq(pubsub_iq("set", self.service, nil, "create", self.node), callback);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
162 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
163 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
164
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
165 -- <configure/> and <default/> rolled into one
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
166 function pubsub_node:configure(config, callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
167 if config ~= nil then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
168 error("Not implemented yet.");
283
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
169 --[[
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
170 if config == true then
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
171 self.stream:send_iq(pubsub_iq("get", self.service, nil, "configure", self.node)
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
172 , function(reply)
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
173 local form = reply:get_child("pubsub"):get_child("configure"):get_cild("x");
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
174 local config = callback(require"util.dataforms".something(form))
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
175 self.stream:send_iq(pubsub_iq("set", config, ...))
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
176 end);
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
177 end
39ce7535887c plugins.pubsub: Add a local variable to save some table lookups
Kim Alvefur <zash@zash.se>
parents: 272
diff changeset
178 --]]
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
179 -- fetch form and pass it to the callback
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
180 -- which would process it and pass it back
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
181 -- and then we submit it
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
182 -- elseif type(config) == "table" then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
183 -- it's a form or stanza that we submit
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
184 -- end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
185 -- this would be done for everything that needs a config
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
186 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
187 self.stream:send_iq(pubsub_iq("set", self.service, nil, config == nil and "default" or "configure", self.node), callback);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
188 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
189
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
190 function pubsub_node:publish(id, options, node, callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
191 if options ~= nil then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
192 error("Node configuration is not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
193 end
263
598e9f93de78 plugins.pubsub: Fix missing <item/> when publishing.
Kim Alvefur <zash@zash.se>
parents: 250
diff changeset
194 self.stream:send_iq(pubsub_iq("set", self.service, nil, "publish", self.node, nil, id or true)
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
195 :add_child(node)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
196 , callback);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
197 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
198
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
199 function pubsub_node:subscribe(jid, options, callback)
332
6ecf44918156 plugins.pubsub: Explicitly subscribe with our current full jid as default
Kim Alvefur <zash@zash.se>
parents: 283
diff changeset
200 jid = jid or self.stream.jid;
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
201 if options ~= nil then
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
202 error("Subscription configuration is not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
203 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
204 self.stream:send_iq(pubsub_iq("set", self.service, nil, "subscribe", self.node, jid, id)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
205 , callback);
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
206 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
207
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
208 function pubsub_node:subscription(callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
209 error("Not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
210 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
211
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
212 function pubsub_node:affiliation(callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
213 error("Not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
214 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
215
272
e1833e9bd25b plugins.pubsub: Implement unsubscribe.
Kim Alvefur <zash@zash.se>
parents: 265
diff changeset
216 function pubsub_node:unsubscribe(jid, callback)
e1833e9bd25b plugins.pubsub: Implement unsubscribe.
Kim Alvefur <zash@zash.se>
parents: 265
diff changeset
217 self.stream:send_iq(pubsub_iq("set", self.service, nil, "unsubscribe", self.node, jid)
e1833e9bd25b plugins.pubsub: Implement unsubscribe.
Kim Alvefur <zash@zash.se>
parents: 265
diff changeset
218 , callback);
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
219 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
220
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
221 function pubsub_node:configure_subscription(options, callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
222 error("Not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
223 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
224
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
225 function pubsub_node:items(count, callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
226 error("Not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
227 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
228
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
229 function pubsub_node:item(id, callback)
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
230 error("Not implemented yet.");
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
231 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
232
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
233 function pubsub_node:retract(id, callback)
333
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
234 self.stream:send_iq(pubsub_iq("set", self.service, nil, "retract", self.node, nil, id)
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
235 , callback);
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
236 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
237
333
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
238 function pubsub_node:purge(notify, callback)
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
239 assert(not notify, "Not implemented yet.");
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
240 self.stream:send_iq(pubsub_iq("set", self.service, xmlns_pubsub_owner, "purge", self.node)
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
241 , callback);
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
242 end
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
243
333
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
244 function pubsub_node:delete(redirect_uri, callback)
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
245 assert(not redirect_uri, "Not implemented yet.");
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
246 self.stream:send_iq(pubsub_iq("set", self.service, xmlns_pubsub_owner, "delete", self.node)
36e9d5a2ae79 plugins.pubsub: Implement retract, purge and delete operations
Kim Alvefur <zash@zash.se>
parents: 332
diff changeset
247 , callback);
222
3c257afd68e7 plugins.pubsub: New, OOP-ish, PubSub interface. Beware of stubs.
Kim Alvefur <zash@zash.se>
parents: 221
diff changeset
248 end