Annotate

plugins/mod_pubsub.lua @ 5312:fdcd2ac7c22d

mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 25 Jan 2013 01:32:14 +0100
parent 5308:fd3219d64414
child 5313:3d63f5236464
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local pubsub = require "util.pubsub";
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local st = require "util.stanza";
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local jid_bare = require "util.jid".bare;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local uuid_generate = require "util.uuid".generate;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors";
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
5312
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
9 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
11 local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false);
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
12 local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false);
4246
d0767040236f mod_pubsub: Support for setting a disco name
Marco Cirillo <maranda@lightwitch.org>
parents: 4225
diff changeset
13 local pubsub_disco_name = module:get_option("name");
d0767040236f mod_pubsub: Support for setting a disco name
Marco Cirillo <maranda@lightwitch.org>
parents: 4225
diff changeset
14 if type(pubsub_disco_name) ~= "string" then pubsub_disco_name = "Prosody PubSub Service"; end
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
15
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 local service;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 local handlers = {};
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 function handle_pubsub_iq(event)
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 local origin, stanza = event.origin, event.stanza;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 local pubsub = stanza.tags[1];
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 local action = pubsub.tags[1];
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 local handler = handlers[stanza.attr.type.."_"..action.name];
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 if handler then
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 handler(origin, stanza, action);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 return true;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 local pubsub_errors = {
3697
67c01f75af97 mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents: 3672
diff changeset
32 ["conflict"] = { "cancel", "conflict" };
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" };
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 ["item-not-found"] = { "cancel", "item-not-found" };
3698
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
35 ["not-subscribed"] = { "modify", "unexpected-request", nil, "not-subscribed" };
3908
4d8081c35f01 mod_pubsub: Add 'forbidden' error support
Matthew Wild <mwild1@gmail.com>
parents: 3761
diff changeset
36 ["forbidden"] = { "cancel", "forbidden" };
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 };
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 function pubsub_error_reply(stanza, error)
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local e = pubsub_errors[error];
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local reply = st.error_reply(stanza, unpack(e, 1, 3));
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 if e[4] then
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up();
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 return reply;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46
3641
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
47 function handlers.get_items(origin, stanza, items)
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
48 local node = items.attr.node;
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
49 local item = items:get_child("item");
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
50 local id = item and item.attr.id;
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
51
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
52 local ok, results = service:get_items(node, stanza.attr.from, id);
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
53 if not ok then
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
54 return origin.send(pubsub_error_reply(stanza, results));
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
55 end
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
56
3641
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
57 local data = st.stanza("items", { node = node });
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
58 for _, entry in pairs(results) do
3641
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
59 data:add_child(entry);
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
60 end
4795
8a105eb8aeae mod_pubsub.lua: Fix global access
Kim Alvefur <zash@zash.se>
parents: 4343
diff changeset
61 local reply;
3641
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
62 if data then
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
63 reply = st.reply(stanza)
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
64 :tag("pubsub", { xmlns = xmlns_pubsub })
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
65 :add_child(data);
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
66 else
3697
67c01f75af97 mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents: 3672
diff changeset
67 reply = pubsub_error_reply(stanza, "item-not-found");
3641
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
68 end
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
69 return origin.send(reply);
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
70 end
3603aeb325de mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents: 3622
diff changeset
71
3941
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
72 function handlers.get_subscriptions(origin, stanza, subscriptions)
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
73 local node = subscriptions.attr.node;
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
74 local ok, ret = service:get_subscriptions(node, stanza.attr.from, stanza.attr.from);
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
75 if not ok then
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
76 return origin.send(pubsub_error_reply(stanza, ret));
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
77 end
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
78 local reply = st.reply(stanza)
3988
a3104064e905 mod_pubsub: Correctly wrap the list of subscriptions in a pubsub element
Kim Alvefur <zash@zash.se>
parents: 3949
diff changeset
79 :tag("pubsub", { xmlns = xmlns_pubsub })
a3104064e905 mod_pubsub: Correctly wrap the list of subscriptions in a pubsub element
Kim Alvefur <zash@zash.se>
parents: 3949
diff changeset
80 :tag("subscriptions");
3941
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
81 for _, sub in ipairs(ret) do
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
82 reply:tag("subscription", { node = sub.node, jid = sub.jid, subscription = 'subscribed' }):up();
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
83 end
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
84 return origin.send(reply);
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
85 end
526624f7852e mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents: 3940
diff changeset
86
3672
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
87 function handlers.set_create(origin, stanza, create)
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
88 local node = create.attr.node;
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
89 local ok, ret, reply;
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
90 if node then
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
91 ok, ret = service:create(node, stanza.attr.from);
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
92 if ok then
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
93 reply = st.reply(stanza);
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
94 else
3697
67c01f75af97 mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents: 3672
diff changeset
95 reply = pubsub_error_reply(stanza, ret);
3672
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
96 end
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
97 else
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
98 repeat
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
99 node = uuid_generate();
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
100 ok, ret = service:create(node, stanza.attr.from);
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
101 until ok or ret ~= "conflict";
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
102 if ok then
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
103 reply = st.reply(stanza)
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
104 :tag("pubsub", { xmlns = xmlns_pubsub })
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
105 :tag("create", { node = node });
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
106 else
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
107 reply = pubsub_error_reply(stanza, ret);
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
108 end
3672
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
109 end
3699
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
110 return origin.send(reply);
3672
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
111 end
b24db47995ac mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents: 3641
diff changeset
112
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 function handlers.set_subscribe(origin, stanza, subscribe)
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 local node, jid = subscribe.attr.node, subscribe.attr.jid;
5308
fd3219d64414 mod_pubsub: Ignore subscription options for now, fixes traceback due to missing form
Kim Alvefur <zash@zash.se>
parents: 5305
diff changeset
115 --[[
4340
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
116 local options_tag, options = stanza.tags[1]:get_child("options"), nil;
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
117 if options_tag then
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
118 options = options_form:data(options_tag.tags[1]);
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
119 end
5308
fd3219d64414 mod_pubsub: Ignore subscription options for now, fixes traceback due to missing form
Kim Alvefur <zash@zash.se>
parents: 5305
diff changeset
120 --]]
fd3219d64414 mod_pubsub: Ignore subscription options for now, fixes traceback due to missing form
Kim Alvefur <zash@zash.se>
parents: 5305
diff changeset
121 local options_tag, options; -- FIXME
4340
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
122 local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options);
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 local reply;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 if ok then
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 reply = st.reply(stanza)
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 :tag("pubsub", { xmlns = xmlns_pubsub })
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 :tag("subscription", {
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 node = node,
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 jid = jid,
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 subscription = "subscribed"
4340
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
131 }):up();
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
132 if options_tag then
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
133 reply:add_child(options_tag);
76420412520e mod_pubsub: Handle options tag in subscription request (currently doesn't work as options_form is not defined)
Matthew Wild <mwild1@gmail.com>
parents: 4246
diff changeset
134 end
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 else
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 reply = pubsub_error_reply(stanza, ret);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 end
4342
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
138 origin.send(reply);
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
139 if ok then
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
140 -- Send all current items
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
141 local ok, items = service:get_items(node, stanza.attr.from);
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
142 if items then
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
143 local jids = { [jid] = options or true };
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
144 for id, item in pairs(items) do
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
145 service.config.broadcaster(node, jids, item);
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
146 end
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
147 end
735d39538944 mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents: 4341
diff changeset
148 end
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150
3698
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
151 function handlers.set_unsubscribe(origin, stanza, unsubscribe)
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
152 local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid;
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
153 local ok, ret = service:remove_subscription(node, stanza.attr.from, jid);
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
154 local reply;
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
155 if ok then
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
156 reply = st.reply(stanza);
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
157 else
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
158 reply = pubsub_error_reply(stanza, ret);
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
159 end
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
160 return origin.send(reply);
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
161 end
77171fd1dc3c mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents: 3697
diff changeset
162
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 function handlers.set_publish(origin, stanza, publish)
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 local node = publish.attr.node;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 local item = publish:get_child("item");
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 local id = (item and item.attr.id) or uuid_generate();
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 local ok, ret = service:publish(node, stanza.attr.from, id, item);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 local reply;
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 if ok then
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 reply = st.reply(stanza)
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 :tag("pubsub", { xmlns = xmlns_pubsub })
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 :tag("publish", { node = node })
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
173 :tag("item", { id = id });
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
174 else
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
175 reply = pubsub_error_reply(stanza, ret);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 return origin.send(reply);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
178 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179
3699
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
180 function handlers.set_retract(origin, stanza, retract)
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
181 local node, notify = retract.attr.node, retract.attr.notify;
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
182 notify = (notify == "1") or (notify == "true");
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
183 local item = retract:get_child("item");
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
184 local id = item and item.attr.id
5305
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
185 if not (node and id) then
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
186 origin.send(st.error_reply(stanza, "modify", "bad-request"));
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
187 return true;
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
188 end
3699
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
189 local reply, notifier;
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
190 if notify then
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
191 notifier = st.stanza("retract", { id = id });
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
192 end
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
193 local ok, ret = service:retract(node, stanza.attr.from, id, notifier);
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
194 if ok then
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
195 reply = st.reply(stanza);
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
196 else
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
197 reply = pubsub_error_reply(stanza, ret);
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
198 end
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
199 return origin.send(reply);
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
200 end
150e58d69e60 mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents: 3698
diff changeset
201
5305
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
202 function handlers.set_purge(origin, stanza, purge)
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
203 local node, notify = purge.attr.node, purge.attr.notify;
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
204 notify = (notify == "1") or (notify == "true");
5312
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
205 local reply;
5305
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
206 if not node then
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
207 origin.send(st.error_reply(stanza, "modify", "bad-request"));
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
208 return true;
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
209 end
5312
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
210 local ok, ret = service:purge(node, stanza.attr.from, notify);
5305
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
211 if ok then
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
212 reply = st.reply(stanza);
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
213 else
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
214 reply = pubsub_error_reply(stanza, ret);
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
215 end
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
216 return origin.send(reply);
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
217 end
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
218
5312
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
219 function simple_broadcast(kind, node, jids, item)
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
220 if item then
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
221 item = st.clone(item);
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
222 item.attr.xmlns = nil; -- Clear the pubsub namespace
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
223 end
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
224 local message = st.message({ from = module.host, type = "headline" })
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
225 :tag("event", { xmlns = xmlns_pubsub_event })
5312
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
226 :tag(kind, { node = node })
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227 :add_child(item);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228 for jid in pairs(jids) do
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
229 module:log("debug", "Sending notification to %s", jid);
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
230 message.attr.to = jid;
5014
b2006c1cfa85 mod_announce, mod_motd, mod_pubsub, mod_register, mod_watchregistrations, mod_welcome: Use module:send() instead of core_*_stanza()
Kim Alvefur <zash@zash.se>
parents: 4795
diff changeset
231 module:send(message);
3619
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
232 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 end
291ae816d800 mod_pubsub: It's aliiiive!
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234
5312
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
235 module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq);
fdcd2ac7c22d mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents: 5308
diff changeset
236 module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq);
3621
7e1a1dd42088 mod_pubsub: Expose 'service'
Matthew Wild <mwild1@gmail.com>
parents: 3619
diff changeset
237
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
238 local disco_info;
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
239
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
240 local feature_map = {
5304
67a49d47ef39 mod_pubsub: Advertise autocreate_on_publish correctly.
Kim Alvefur <zash@zash.se>
parents: 5014
diff changeset
241 create = { "create-nodes", "instant-nodes", "item-ids" };
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
242 retract = { "delete-items", "retract-items" };
5305
391b72fede9f mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents: 5304
diff changeset
243 purge = { "purge-nodes" };
5304
67a49d47ef39 mod_pubsub: Advertise autocreate_on_publish correctly.
Kim Alvefur <zash@zash.se>
parents: 5014
diff changeset
244 publish = { "publish", autocreate_on_publish and "auto-create" };
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
245 get_items = { "retrieve-items" };
3939
b66e9a7593b6 mod_pubsub: Add add_subscription and get_subscriptions to feature_map
Matthew Wild <mwild1@gmail.com>
parents: 3935
diff changeset
246 add_subscription = { "subscribe" };
b66e9a7593b6 mod_pubsub: Add add_subscription and get_subscriptions to feature_map
Matthew Wild <mwild1@gmail.com>
parents: 3935
diff changeset
247 get_subscriptions = { "retrieve-subscriptions" };
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
248 };
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
249
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
250 local function add_disco_features_from_service(disco, service)
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
251 for method, features in pairs(feature_map) do
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
252 if service[method] then
3915
e24fcbb01fb6 mod_pubsub: Iterate over disco features in correct table
Matthew Wild <mwild1@gmail.com>
parents: 3914
diff changeset
253 for _, feature in ipairs(features) do
3918
f30c5bad29b8 mod_pubsub: Skip false features in feature_map
Matthew Wild <mwild1@gmail.com>
parents: 3916
diff changeset
254 if feature then
f30c5bad29b8 mod_pubsub: Skip false features in feature_map
Matthew Wild <mwild1@gmail.com>
parents: 3916
diff changeset
255 disco:tag("feature", { var = xmlns_pubsub.."#"..feature }):up();
f30c5bad29b8 mod_pubsub: Skip false features in feature_map
Matthew Wild <mwild1@gmail.com>
parents: 3916
diff changeset
256 end
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
257 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
258 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
259 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
260 for affiliation in pairs(service.config.capabilities) do
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
261 if affiliation ~= "none" and affiliation ~= "owner" then
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
262 disco:tag("feature", { var = xmlns_pubsub.."#"..affiliation.."-affiliation" }):up();
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
263 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
264 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
265 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
266
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
267 local function build_disco_info(service)
3916
ffe5a0d36f57 mod_pubsub: Return disco#info stanza from build_disco_info()
Matthew Wild <mwild1@gmail.com>
parents: 3915
diff changeset
268 local disco_info = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" })
4246
d0767040236f mod_pubsub: Support for setting a disco name
Marco Cirillo <maranda@lightwitch.org>
parents: 4225
diff changeset
269 :tag("identity", { category = "pubsub", type = "service", name = pubsub_disco_name }):up()
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
270 :tag("feature", { var = "http://jabber.org/protocol/pubsub" }):up();
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
271 add_disco_features_from_service(disco_info, service);
3916
ffe5a0d36f57 mod_pubsub: Return disco#info stanza from build_disco_info()
Matthew Wild <mwild1@gmail.com>
parents: 3915
diff changeset
272 return disco_info;
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
273 end
3760
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
274
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
275 module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function (event)
3944
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
276 local origin, stanza = event.origin, event.stanza;
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
277 local node = stanza.tags[1].attr.node;
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
278 if not node then
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
279 return origin.send(st.reply(stanza):add_child(disco_info));
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
280 else
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
281 local ok, ret = service:get_nodes(stanza.attr.from);
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
282 if ok and not ret[node] then
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
283 ok, ret = false, "item-not-found";
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
284 end
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
285 if not ok then
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
286 return origin.send(pubsub_error_reply(stanza, ret));
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
287 end
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
288 local reply = st.reply(stanza)
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
289 :tag("query", { xmlns = "http://jabber.org/protocol/disco#info", node = node })
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
290 :tag("identity", { category = "pubsub", type = "leaf" });
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
291 return origin.send(reply);
74a422abec11 mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents: 3941
diff changeset
292 end
3760
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
293 end);
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
294
3932
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
295 local function handle_disco_items_on_node(event)
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
296 local stanza, origin = event.stanza, event.origin;
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
297 local query = stanza.tags[1];
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
298 local node = query.attr.node;
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
299 local ok, ret = service:get_items(node, stanza.attr.from);
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
300 if not ok then
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
301 return origin.send(pubsub_error_reply(stanza, ret));
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
302 end
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
303
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
304 local reply = st.reply(stanza)
3949
fc4ff6db1e57 mod_pubsub: Include node in disco#items reply
Matthew Wild <mwild1@gmail.com>
parents: 3946
diff changeset
305 :tag("query", { xmlns = "http://jabber.org/protocol/disco#items", node = node });
3932
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
306
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
307 for id, item in pairs(ret) do
3933
24f0a7544a7a mod_pubsub: Fix a missing :up() from the last commit
Matthew Wild <mwild1@gmail.com>
parents: 3932
diff changeset
308 reply:tag("item", { jid = module.host, name = id }):up();
3932
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
309 end
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
310
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
311 return origin.send(reply);
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
312 end
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
313
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
314
3760
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
315 module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function (event)
3932
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
316 if event.stanza.tags[1].attr.node then
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
317 return handle_disco_items_on_node(event);
aa245e43b21e mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents: 3919
diff changeset
318 end
3760
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
319 local ok, ret = service:get_nodes(event.stanza.attr.from);
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
320 if not ok then
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
321 event.origin.send(pubsub_error_reply(stanza, ret));
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
322 else
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
323 local reply = st.reply(event.stanza)
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
324 :tag("query", { xmlns = "http://jabber.org/protocol/disco#items" });
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
325 for node, node_obj in pairs(ret) do
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
326 reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up();
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
327 end
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
328 event.origin.send(reply);
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
329 end
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
330 return true;
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
331 end);
3bfb65496773 mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents: 3700
diff changeset
332
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
333 local admin_aff = module:get_option_string("default_admin_affiliation", "owner");
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
334 local function get_affiliation(jid)
3919
e288372dd19f mod_pubsub: Use bare JID in get_affiliation
Matthew Wild <mwild1@gmail.com>
parents: 3918
diff changeset
335 local bare_jid = jid_bare(jid);
e288372dd19f mod_pubsub: Use bare JID in get_affiliation
Matthew Wild <mwild1@gmail.com>
parents: 3918
diff changeset
336 if bare_jid == module.host or usermanager.is_admin(bare_jid, module.host) then
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
337 return admin_aff;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
338 end
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
339 end
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
340
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
341 function set_service(new_service)
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
342 service = new_service;
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
343 module.environment.service = service;
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
344 disco_info = build_disco_info(service);
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
345 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
346
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
347 function module.save()
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
348 return { service = service };
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
349 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
350
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
351 function module.restore(data)
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
352 set_service(data.service);
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
353 end
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
354
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
355 set_service(pubsub.new({
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
356 capabilities = {
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
357 none = {
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
358 create = false;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
359 publish = false;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
360 retract = false;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
361 get_nodes = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
362
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
363 subscribe = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
364 unsubscribe = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
365 get_subscription = true;
3940
d55e67e4191a mod_pubsub: Add get_subscriptions and get_subscriptions_other capabilities to default affiliations
Matthew Wild <mwild1@gmail.com>
parents: 3939
diff changeset
366 get_subscriptions = true;
3913
e748d29b18d6 mod_pubsub: Fix capabilities table from some debugging
Matthew Wild <mwild1@gmail.com>
parents: 3912
diff changeset
367 get_items = true;
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
368
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
369 subscribe_other = false;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
370 unsubscribe_other = false;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
371 get_subscription_other = false;
3940
d55e67e4191a mod_pubsub: Add get_subscriptions and get_subscriptions_other capabilities to default affiliations
Matthew Wild <mwild1@gmail.com>
parents: 3939
diff changeset
372 get_subscriptions_other = false;
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
373
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
374 be_subscribed = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
375 be_unsubscribed = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
376
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
377 set_affiliation = false;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
378 };
4343
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
379 publisher = {
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
380 create = false;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
381 publish = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
382 retract = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
383 get_nodes = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
384
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
385 subscribe = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
386 unsubscribe = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
387 get_subscription = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
388 get_subscriptions = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
389 get_items = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
390
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
391 subscribe_other = false;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
392 unsubscribe_other = false;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
393 get_subscription_other = false;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
394 get_subscriptions_other = false;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
395
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
396 be_subscribed = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
397 be_unsubscribed = true;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
398
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
399 set_affiliation = false;
203137823046 mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents: 4342
diff changeset
400 };
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
401 owner = {
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
402 create = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
403 publish = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
404 retract = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
405 get_nodes = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
406
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
407 subscribe = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
408 unsubscribe = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
409 get_subscription = true;
3940
d55e67e4191a mod_pubsub: Add get_subscriptions and get_subscriptions_other capabilities to default affiliations
Matthew Wild <mwild1@gmail.com>
parents: 3939
diff changeset
410 get_subscriptions = true;
3913
e748d29b18d6 mod_pubsub: Fix capabilities table from some debugging
Matthew Wild <mwild1@gmail.com>
parents: 3912
diff changeset
411 get_items = true;
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
412
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
413
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
414 subscribe_other = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
415 unsubscribe_other = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
416 get_subscription_other = true;
3940
d55e67e4191a mod_pubsub: Add get_subscriptions and get_subscriptions_other capabilities to default affiliations
Matthew Wild <mwild1@gmail.com>
parents: 3939
diff changeset
417 get_subscriptions_other = true;
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
418
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
419 be_subscribed = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
420 be_unsubscribed = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
421
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
422 set_affiliation = true;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
423 };
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
424 };
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
425
3914
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
426 autocreate_on_publish = autocreate_on_publish;
f10282c2e410 mod_pubsub: Build disco#info based on the methods provided by the pubsub service object. Add public set_service() method to change the service object used by the module.
Matthew Wild <mwild1@gmail.com>
parents: 3913
diff changeset
427 autocreate_on_subscribe = autocreate_on_subscribe;
3911
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
428
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
429 broadcaster = simple_broadcast;
a99a2bb7a6ec mod_pubsub: Update for latest util.pubsub and fix some bugs. New config options autocreate_on_publish, autocreate_on_subscribe and default_admin_affiliation.
Matthew Wild <mwild1@gmail.com>
parents: 3908
diff changeset
430 get_affiliation = get_affiliation;
3935
2733b56f23b0 mod_pubsub: Set normalize_jid instead of jids_equal
Matthew Wild <mwild1@gmail.com>
parents: 3933
diff changeset
431
2733b56f23b0 mod_pubsub: Set normalize_jid instead of jids_equal
Matthew Wild <mwild1@gmail.com>
parents: 3933
diff changeset
432 normalize_jid = jid_bare;
4341
225d46be7301 mod_pubsub: Add newline at end of file
Matthew Wild <mwild1@gmail.com>
parents: 4340
diff changeset
433 }));