Software / code / prosody
Annotate
plugins/mod_pubsub.lua @ 5477:50cbea68586f
net.http.parser: Remove accidentally-committed debugging
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 15 Apr 2013 21:25:59 +0100 |
| parent | 5445:9054b51e71a4 |
| child | 5479:81c599c7588b |
| rev | line source |
|---|---|
| 3619 | 1 local pubsub = require "util.pubsub"; |
| 2 local st = require "util.stanza"; | |
| 3 local jid_bare = require "util.jid".bare; | |
| 4 local uuid_generate = require "util.uuid".generate; | |
|
5314
e5e480d73066
mod_pubsub: require usermanager.
Waqas Hussain <waqas20@gmail.com>
parents:
5313
diff
changeset
|
5 local usermanager = require "core.usermanager"; |
| 3619 | 6 |
| 7 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | |
| 8 local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; | |
| 9 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
|
10 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; |
| 3619 | 11 |
|
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
|
12 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
|
13 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
|
14 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
|
15 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
|
16 |
| 3619 | 17 local service; |
| 18 | |
| 19 local handlers = {}; | |
| 20 | |
| 21 function handle_pubsub_iq(event) | |
| 22 local origin, stanza = event.origin, event.stanza; | |
| 23 local pubsub = stanza.tags[1]; | |
| 24 local action = pubsub.tags[1]; | |
|
5445
9054b51e71a4
mod_pubsub: Send bad-request when no action specified (thanks Maranda)
Matthew Wild <mwild1@gmail.com>
parents:
5443
diff
changeset
|
25 if not action then |
|
9054b51e71a4
mod_pubsub: Send bad-request when no action specified (thanks Maranda)
Matthew Wild <mwild1@gmail.com>
parents:
5443
diff
changeset
|
26 return origin.send(st.error_reply(stanza, "cancel", "bad-request")); |
|
9054b51e71a4
mod_pubsub: Send bad-request when no action specified (thanks Maranda)
Matthew Wild <mwild1@gmail.com>
parents:
5443
diff
changeset
|
27 end |
| 3619 | 28 local handler = handlers[stanza.attr.type.."_"..action.name]; |
| 29 if handler then | |
| 30 handler(origin, stanza, action); | |
| 31 return true; | |
| 32 end | |
| 33 end | |
| 34 | |
| 35 local pubsub_errors = { | |
|
3697
67c01f75af97
mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents:
3672
diff
changeset
|
36 ["conflict"] = { "cancel", "conflict" }; |
| 3619 | 37 ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" }; |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
38 ["jid-required"] = { "modify", "bad-request", nil, "jid-required" }; |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
39 ["nodeid-required"] = { "modify", "bad-request", nil, "nodeid-required" }; |
| 3619 | 40 ["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
|
41 ["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
|
42 ["forbidden"] = { "cancel", "forbidden" }; |
| 3619 | 43 }; |
| 44 function pubsub_error_reply(stanza, error) | |
| 45 local e = pubsub_errors[error]; | |
| 46 local reply = st.error_reply(stanza, unpack(e, 1, 3)); | |
| 47 if e[4] then | |
| 48 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up(); | |
| 49 end | |
| 50 return reply; | |
| 51 end | |
| 52 | |
|
3641
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
53 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
|
54 local node = items.attr.node; |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
55 local item = items:get_child("item"); |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
56 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
|
57 |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
58 if not node then |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
59 return origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
60 end |
|
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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 |
|
3641
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
66 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
|
67 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
|
68 data:add_child(entry); |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
69 end |
|
4795
8a105eb8aeae
mod_pubsub.lua: Fix global access
Kim Alvefur <zash@zash.se>
parents:
4343
diff
changeset
|
70 local reply; |
|
3641
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
71 if data then |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
72 reply = st.reply(stanza) |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
73 :tag("pubsub", { xmlns = xmlns_pubsub }) |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
74 :add_child(data); |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
75 else |
|
3697
67c01f75af97
mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents:
3672
diff
changeset
|
76 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
|
77 end |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
78 return origin.send(reply); |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
79 end |
|
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
80 |
|
3941
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
81 function handlers.get_subscriptions(origin, stanza, subscriptions) |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
82 local node = subscriptions.attr.node; |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
83 if not node then |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
84 return origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
85 end |
|
3941
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
86 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
|
87 if not ok then |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
88 return origin.send(pubsub_error_reply(stanza, ret)); |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
89 end |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
90 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
|
91 :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
|
92 :tag("subscriptions"); |
|
3941
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
93 for _, sub in ipairs(ret) do |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
94 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
|
95 end |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
96 return origin.send(reply); |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
97 end |
|
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
98 |
|
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
99 function handlers.set_create(origin, stanza, create) |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
100 local node = create.attr.node; |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
101 local ok, ret, reply; |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
102 if node then |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
103 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
|
104 if ok then |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
105 reply = st.reply(stanza); |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
106 else |
|
3697
67c01f75af97
mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents:
3672
diff
changeset
|
107 reply = pubsub_error_reply(stanza, ret); |
|
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
108 end |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
109 else |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
110 repeat |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
111 node = uuid_generate(); |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 :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
|
117 :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
|
118 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
|
119 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
|
120 end |
|
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
121 end |
|
3699
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
122 return origin.send(reply); |
|
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
123 end |
|
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
124 |
|
5320
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
125 function handlers.set_delete(origin, stanza, delete) |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
126 local node = delete.attr.node; |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
127 |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
128 local reply, notifier; |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
129 if not node then |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
130 return origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
131 end |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
132 local ok, ret = service:delete(node, stanza.attr.from); |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
133 if ok then |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
134 reply = st.reply(stanza); |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
135 else |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
136 reply = pubsub_error_reply(stanza, ret); |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
137 end |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
138 return origin.send(reply); |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
139 end |
|
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
140 |
| 3619 | 141 function handlers.set_subscribe(origin, stanza, subscribe) |
| 142 local node, jid = subscribe.attr.node, subscribe.attr.jid; | |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
143 if not (node and jid) then |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
144 return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
145 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
|
146 --[[ |
|
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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 --]] |
|
fd3219d64414
mod_pubsub: Ignore subscription options for now, fixes traceback due to missing form
Kim Alvefur <zash@zash.se>
parents:
5305
diff
changeset
|
152 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
|
153 local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options); |
| 3619 | 154 local reply; |
| 155 if ok then | |
| 156 reply = st.reply(stanza) | |
| 157 :tag("pubsub", { xmlns = xmlns_pubsub }) | |
| 158 :tag("subscription", { | |
| 159 node = node, | |
| 160 jid = jid, | |
| 161 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
|
162 }):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
|
163 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
|
164 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
|
165 end |
| 3619 | 166 else |
| 167 reply = pubsub_error_reply(stanza, ret); | |
| 168 end | |
|
4342
735d39538944
mod_pubsub: Send node items to new subscribers
Matthew Wild <mwild1@gmail.com>
parents:
4341
diff
changeset
|
169 origin.send(reply); |
| 3619 | 170 end |
| 171 | |
|
3698
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
172 function handlers.set_unsubscribe(origin, stanza, unsubscribe) |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
173 local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid; |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
174 if not (node and jid) then |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
175 return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
176 end |
|
3698
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
177 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
|
178 local reply; |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
179 if ok then |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
180 reply = st.reply(stanza); |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
181 else |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
182 reply = pubsub_error_reply(stanza, ret); |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
183 end |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
184 return origin.send(reply); |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
185 end |
|
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
186 |
| 3619 | 187 function handlers.set_publish(origin, stanza, publish) |
| 188 local node = publish.attr.node; | |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
189 if not node then |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
190 return origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
|
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
191 end |
| 3619 | 192 local item = publish:get_child("item"); |
| 193 local id = (item and item.attr.id) or uuid_generate(); | |
| 194 local ok, ret = service:publish(node, stanza.attr.from, id, item); | |
| 195 local reply; | |
| 196 if ok then | |
| 197 reply = st.reply(stanza) | |
| 198 :tag("pubsub", { xmlns = xmlns_pubsub }) | |
| 199 :tag("publish", { node = node }) | |
| 200 :tag("item", { id = id }); | |
| 201 else | |
| 202 reply = pubsub_error_reply(stanza, ret); | |
| 203 end | |
| 204 return origin.send(reply); | |
| 205 end | |
| 206 | |
|
3699
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
207 function handlers.set_retract(origin, stanza, retract) |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
208 local node, notify = retract.attr.node, retract.attr.notify; |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
209 notify = (notify == "1") or (notify == "true"); |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
210 local item = retract:get_child("item"); |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
211 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
|
212 if not (node and id) then |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
213 return origin.send(pubsub_error_reply(stanza, node and "item-not-found" or "nodeid-required")); |
|
5305
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
214 end |
|
3699
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
215 local reply, notifier; |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
216 if notify then |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
217 notifier = st.stanza("retract", { id = id }); |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
218 end |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
219 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
|
220 if ok then |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
221 reply = st.reply(stanza); |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
222 else |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
223 reply = pubsub_error_reply(stanza, ret); |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
224 end |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
225 return origin.send(reply); |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
226 end |
|
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
227 |
|
5305
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 local reply; |
|
5305
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
232 if not node then |
|
5318
989acb4ad1de
mod_pubsub: More strict checks for node and ids
Kim Alvefur <zash@zash.se>
parents:
5317
diff
changeset
|
233 return origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
|
5305
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
234 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
|
235 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
|
236 if ok then |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
237 reply = st.reply(stanza); |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
238 else |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
239 reply = pubsub_error_reply(stanza, ret); |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
240 end |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
241 return origin.send(reply); |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
242 end |
|
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
243 |
|
5312
fdcd2ac7c22d
mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents:
5308
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 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
|
248 end |
| 3619 | 249 local message = st.message({ from = module.host, type = "headline" }) |
| 250 :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
|
251 :tag(kind, { node = node }) |
| 3619 | 252 :add_child(item); |
| 253 for jid in pairs(jids) do | |
| 254 module:log("debug", "Sending notification to %s", jid); | |
| 255 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
|
256 module:send(message); |
| 3619 | 257 end |
| 258 end | |
| 259 | |
|
5312
fdcd2ac7c22d
mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Florian Zeitz <florob@babelmonkeys.de>
parents:
5308
diff
changeset
|
260 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
|
261 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
|
262 |
|
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
|
263 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
|
264 |
|
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 local feature_map = { |
|
5304
67a49d47ef39
mod_pubsub: Advertise autocreate_on_publish correctly.
Kim Alvefur <zash@zash.se>
parents:
5014
diff
changeset
|
266 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
|
267 retract = { "delete-items", "retract-items" }; |
|
5305
391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
Kim Alvefur <zash@zash.se>
parents:
5304
diff
changeset
|
268 purge = { "purge-nodes" }; |
|
5304
67a49d47ef39
mod_pubsub: Advertise autocreate_on_publish correctly.
Kim Alvefur <zash@zash.se>
parents:
5014
diff
changeset
|
269 publish = { "publish", autocreate_on_publish and "auto-create" }; |
|
5320
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
270 delete = { "delete-nodes" }; |
|
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
|
271 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
|
272 add_subscription = { "subscribe" }; |
|
b66e9a7593b6
mod_pubsub: Add add_subscription and get_subscriptions to feature_map
Matthew Wild <mwild1@gmail.com>
parents:
3935
diff
changeset
|
273 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
|
274 }; |
|
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
|
275 |
|
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
|
276 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
|
277 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
|
278 if service[method] then |
|
3915
e24fcbb01fb6
mod_pubsub: Iterate over disco features in correct table
Matthew Wild <mwild1@gmail.com>
parents:
3914
diff
changeset
|
279 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
|
280 if feature then |
|
f30c5bad29b8
mod_pubsub: Skip false features in feature_map
Matthew Wild <mwild1@gmail.com>
parents:
3916
diff
changeset
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 |
|
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
|
293 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
|
294 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
|
295 :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
|
296 :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
|
297 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
|
298 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
|
299 end |
|
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
300 |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
301 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
|
302 local origin, stanza = event.origin, event.stanza; |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
303 local node = stanza.tags[1].attr.node; |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
304 if not node then |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
305 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
|
306 else |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
307 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
|
308 if ok and not ret[node] then |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
309 ok, ret = false, "item-not-found"; |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
310 end |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
311 if not ok then |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
312 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
|
313 end |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
314 local reply = st.reply(stanza) |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
315 :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
|
316 :tag("identity", { category = "pubsub", type = "leaf" }); |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
317 return origin.send(reply); |
|
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
318 end |
|
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
319 end); |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
320 |
|
3932
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
321 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
|
322 local stanza, origin = event.stanza, event.origin; |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
323 local query = stanza.tags[1]; |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
324 local node = query.attr.node; |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
325 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
|
326 if not ok then |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
327 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
|
328 end |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
329 |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
330 local reply = st.reply(stanza) |
|
3949
fc4ff6db1e57
mod_pubsub: Include node in disco#items reply
Matthew Wild <mwild1@gmail.com>
parents:
3946
diff
changeset
|
331 :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
|
332 |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
333 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
|
334 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
|
335 end |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
336 |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
337 return origin.send(reply); |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
338 end |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
339 |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
340 |
|
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
341 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
|
342 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
|
343 return handle_disco_items_on_node(event); |
|
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
344 end |
|
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
345 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
|
346 if not ok then |
|
5313
3d63f5236464
mod_pubsub: Fix nil access error.
Waqas Hussain <waqas20@gmail.com>
parents:
5312
diff
changeset
|
347 event.origin.send(pubsub_error_reply(event.stanza, ret)); |
|
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
348 else |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
349 local reply = st.reply(event.stanza) |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
350 :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
|
351 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
|
352 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
|
353 end |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
354 event.origin.send(reply); |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
355 end |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
356 return true; |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
357 end); |
|
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
358 |
|
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
|
359 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
|
360 local function get_affiliation(jid) |
|
3919
e288372dd19f
mod_pubsub: Use bare JID in get_affiliation
Matthew Wild <mwild1@gmail.com>
parents:
3918
diff
changeset
|
361 local bare_jid = jid_bare(jid); |
|
e288372dd19f
mod_pubsub: Use bare JID in get_affiliation
Matthew Wild <mwild1@gmail.com>
parents:
3918
diff
changeset
|
362 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
|
363 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
|
364 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
|
365 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
|
366 |
|
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
|
367 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 |
|
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
|
373 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
|
374 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
|
375 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
|
376 |
|
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
|
377 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
|
378 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
|
379 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
|
380 |
|
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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 |
|
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
|
389 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
|
390 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
|
391 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
|
392 get_subscriptions = true; |
|
3913
e748d29b18d6
mod_pubsub: Fix capabilities table from some debugging
Matthew Wild <mwild1@gmail.com>
parents:
3912
diff
changeset
|
393 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
|
394 |
|
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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 |
|
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
|
400 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
|
401 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
|
402 |
|
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 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
|
404 }; |
|
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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 |
|
203137823046
mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents:
4342
diff
changeset
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 |
|
203137823046
mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents:
4342
diff
changeset
|
417 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
|
418 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
|
419 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
|
420 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
|
421 |
|
203137823046
mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents:
4342
diff
changeset
|
422 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
|
423 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
|
424 |
|
203137823046
mod_pubsub: Add 'publisher' affiliation (can't create/configure nodes, can do everything else)
Matthew Wild <mwild1@gmail.com>
parents:
4342
diff
changeset
|
425 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
|
426 }; |
|
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
|
427 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
|
428 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
|
429 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
|
430 retract = true; |
|
5320
518d864b2ab8
mod_pubsub, util.pubsub: Add delete action
Kim Alvefur <zash@zash.se>
parents:
5318
diff
changeset
|
431 delete = 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
|
432 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
|
433 |
|
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
|
434 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
|
435 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
|
436 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
|
437 get_subscriptions = true; |
|
3913
e748d29b18d6
mod_pubsub: Fix capabilities table from some debugging
Matthew Wild <mwild1@gmail.com>
parents:
3912
diff
changeset
|
438 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
|
439 |
|
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
|
440 |
|
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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 |
|
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
|
446 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
|
447 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
|
448 |
|
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
|
449 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
|
450 }; |
|
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
|
451 }; |
|
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
|
452 |
|
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
|
453 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
|
454 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
|
455 |
|
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
|
456 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
|
457 get_affiliation = get_affiliation; |
|
3935
2733b56f23b0
mod_pubsub: Set normalize_jid instead of jids_equal
Matthew Wild <mwild1@gmail.com>
parents:
3933
diff
changeset
|
458 |
|
2733b56f23b0
mod_pubsub: Set normalize_jid instead of jids_equal
Matthew Wild <mwild1@gmail.com>
parents:
3933
diff
changeset
|
459 normalize_jid = jid_bare; |
|
4341
225d46be7301
mod_pubsub: Add newline at end of file
Matthew Wild <mwild1@gmail.com>
parents:
4340
diff
changeset
|
460 })); |