Software /
code /
prosody
Annotate
plugins/mod_pubsub.lua @ 4251:96e9d5f9ab3b
net.dns: Fix TXT records
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 15 Apr 2011 00:54:10 +0200 |
parent | 4246:d0767040236f |
child | 4340:76420412520e |
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; | |
5 | |
6 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | |
7 local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; | |
8 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; | |
9 | |
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
|
10 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
|
11 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
|
12 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
|
13 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
|
14 |
3619 | 15 local service; |
16 | |
17 local handlers = {}; | |
18 | |
19 function handle_pubsub_iq(event) | |
20 local origin, stanza = event.origin, event.stanza; | |
21 local pubsub = stanza.tags[1]; | |
22 local action = pubsub.tags[1]; | |
23 local handler = handlers[stanza.attr.type.."_"..action.name]; | |
24 if handler then | |
25 handler(origin, stanza, action); | |
26 return true; | |
27 end | |
28 end | |
29 | |
30 local pubsub_errors = { | |
3697
67c01f75af97
mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents:
3672
diff
changeset
|
31 ["conflict"] = { "cancel", "conflict" }; |
3619 | 32 ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" }; |
33 ["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
|
34 ["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
|
35 ["forbidden"] = { "cancel", "forbidden" }; |
3619 | 36 }; |
37 function pubsub_error_reply(stanza, error) | |
38 local e = pubsub_errors[error]; | |
39 local reply = st.error_reply(stanza, unpack(e, 1, 3)); | |
40 if e[4] then | |
41 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up(); | |
42 end | |
43 return reply; | |
44 end | |
45 | |
3641
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
46 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
|
47 local node = items.attr.node; |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
48 local item = items:get_child("item"); |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
49 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
|
50 |
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 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
|
52 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
|
53 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
|
54 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
|
55 |
3641
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
56 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
|
57 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
|
58 data:add_child(entry); |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
59 end |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
60 if data then |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
61 reply = st.reply(stanza) |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
62 :tag("pubsub", { xmlns = xmlns_pubsub }) |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
63 :add_child(data); |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
64 else |
3697
67c01f75af97
mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents:
3672
diff
changeset
|
65 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
|
66 end |
3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
Florian Zeitz <florob@babelmonkeys.de>
parents:
3622
diff
changeset
|
67 return origin.send(reply); |
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 |
3941
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
70 function handlers.get_subscriptions(origin, stanza, subscriptions) |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
71 local node = subscriptions.attr.node; |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
72 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
|
73 if not ok then |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
74 return origin.send(pubsub_error_reply(stanza, ret)); |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
75 end |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
76 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
|
77 :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
|
78 :tag("subscriptions"); |
3941
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
79 for _, sub in ipairs(ret) do |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
80 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
|
81 end |
526624f7852e
mod_pubsub: Implement get_subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
3940
diff
changeset
|
82 return origin.send(reply); |
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 |
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
85 function handlers.set_create(origin, stanza, create) |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
86 local node = create.attr.node; |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
87 local ok, ret, reply; |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
88 if node then |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
89 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
|
90 if ok then |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
91 reply = st.reply(stanza); |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
92 else |
3697
67c01f75af97
mod_pubsub: Use pubsub_error_reply everywhere
Florian Zeitz <florob@babelmonkeys.de>
parents:
3672
diff
changeset
|
93 reply = pubsub_error_reply(stanza, ret); |
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
94 end |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
95 else |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
96 repeat |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
97 node = uuid_generate(); |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 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
|
102 :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
|
103 :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
|
104 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
|
105 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
|
106 end |
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
107 end |
3699
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
108 return origin.send(reply); |
3672
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
109 end |
b24db47995ac
mod_pubsub, util.pubsub: Support node creation
Florian Zeitz <florob@babelmonkeys.de>
parents:
3641
diff
changeset
|
110 |
3619 | 111 function handlers.set_subscribe(origin, stanza, subscribe) |
112 local node, jid = subscribe.attr.node, subscribe.attr.jid; | |
113 local ok, ret = service:add_subscription(node, stanza.attr.from, jid); | |
114 local reply; | |
115 if ok then | |
116 reply = st.reply(stanza) | |
117 :tag("pubsub", { xmlns = xmlns_pubsub }) | |
118 :tag("subscription", { | |
119 node = node, | |
120 jid = jid, | |
121 subscription = "subscribed" | |
122 }); | |
123 else | |
124 reply = pubsub_error_reply(stanza, ret); | |
125 end | |
126 return origin.send(reply); | |
127 end | |
128 | |
3698
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
129 function handlers.set_unsubscribe(origin, stanza, unsubscribe) |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
130 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
|
131 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
|
132 local reply; |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
133 if ok then |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
134 reply = st.reply(stanza); |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
135 else |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
136 reply = pubsub_error_reply(stanza, ret); |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
137 end |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
138 return origin.send(reply); |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
139 end |
77171fd1dc3c
mod_pubsub, util.pubsub: Support for unsubscribing
Florian Zeitz <florob@babelmonkeys.de>
parents:
3697
diff
changeset
|
140 |
3619 | 141 function handlers.set_publish(origin, stanza, publish) |
142 local node = publish.attr.node; | |
143 local item = publish:get_child("item"); | |
144 local id = (item and item.attr.id) or uuid_generate(); | |
145 local ok, ret = service:publish(node, stanza.attr.from, id, item); | |
146 local reply; | |
147 if ok then | |
148 reply = st.reply(stanza) | |
149 :tag("pubsub", { xmlns = xmlns_pubsub }) | |
150 :tag("publish", { node = node }) | |
151 :tag("item", { id = id }); | |
152 else | |
153 reply = pubsub_error_reply(stanza, ret); | |
154 end | |
155 return origin.send(reply); | |
156 end | |
157 | |
3699
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
158 function handlers.set_retract(origin, stanza, retract) |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
159 local node, notify = retract.attr.node, retract.attr.notify; |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
160 notify = (notify == "1") or (notify == "true"); |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
161 local item = retract:get_child("item"); |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
162 local id = item and item.attr.id |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
163 local reply, notifier; |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
164 if notify then |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
165 notifier = st.stanza("retract", { id = id }); |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
166 end |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
167 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
|
168 if ok then |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
169 reply = st.reply(stanza); |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
170 else |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
171 reply = pubsub_error_reply(stanza, ret); |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
172 end |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
173 return origin.send(reply); |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
174 end |
150e58d69e60
mod_pubsub: Support item retraction
Florian Zeitz <florob@babelmonkeys.de>
parents:
3698
diff
changeset
|
175 |
3619 | 176 function simple_broadcast(node, jids, item) |
3700
c8fcd63e9526
mod_pubsub: Ensure <item> is in correct scope when broadcasting an event
Matthew Wild <mwild1@gmail.com>
parents:
3699
diff
changeset
|
177 item = st.clone(item); |
c8fcd63e9526
mod_pubsub: Ensure <item> is in correct scope when broadcasting an event
Matthew Wild <mwild1@gmail.com>
parents:
3699
diff
changeset
|
178 item.attr.xmlns = nil; -- Clear the pubsub namespace |
3619 | 179 local message = st.message({ from = module.host, type = "headline" }) |
180 :tag("event", { xmlns = xmlns_pubsub_event }) | |
181 :tag("items", { node = node }) | |
182 :add_child(item); | |
183 for jid in pairs(jids) do | |
184 module:log("debug", "Sending notification to %s", jid); | |
185 message.attr.to = jid; | |
186 core_post_stanza(hosts[module.host], message); | |
187 end | |
188 end | |
189 | |
3621
7e1a1dd42088
mod_pubsub: Expose 'service'
Matthew Wild <mwild1@gmail.com>
parents:
3619
diff
changeset
|
190 module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq); |
7e1a1dd42088
mod_pubsub: Expose 'service'
Matthew Wild <mwild1@gmail.com>
parents:
3619
diff
changeset
|
191 |
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
|
192 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
|
193 |
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
|
194 local feature_map = { |
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
|
195 create = { "create-nodes", autocreate_on_publish and "instant-nodes", "item-ids" }; |
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
|
196 retract = { "delete-items", "retract-items" }; |
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
|
197 publish = { "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
|
198 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
|
199 add_subscription = { "subscribe" }; |
b66e9a7593b6
mod_pubsub: Add add_subscription and get_subscriptions to feature_map
Matthew Wild <mwild1@gmail.com>
parents:
3935
diff
changeset
|
200 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
|
201 }; |
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
|
202 |
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
|
203 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
|
204 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
|
205 if service[method] then |
3915
e24fcbb01fb6
mod_pubsub: Iterate over disco features in correct table
Matthew Wild <mwild1@gmail.com>
parents:
3914
diff
changeset
|
206 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
|
207 if feature then |
f30c5bad29b8
mod_pubsub: Skip false features in feature_map
Matthew Wild <mwild1@gmail.com>
parents:
3916
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 |
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
|
220 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
|
221 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
|
222 :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
|
223 :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
|
224 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
|
225 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
|
226 end |
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
227 |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
228 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
|
229 local origin, stanza = event.origin, event.stanza; |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
230 local node = stanza.tags[1].attr.node; |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
231 if not node then |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
232 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
|
233 else |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
234 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
|
235 if ok and not ret[node] then |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
236 ok, ret = false, "item-not-found"; |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
237 end |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
238 if not ok then |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
239 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
|
240 end |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
241 local reply = st.reply(stanza) |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
242 :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
|
243 :tag("identity", { category = "pubsub", type = "leaf" }); |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
244 return origin.send(reply); |
74a422abec11
mod_pubsub: Implement disco#info for nodes
Matthew Wild <mwild1@gmail.com>
parents:
3941
diff
changeset
|
245 end |
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
246 end); |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
247 |
3932
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
248 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
|
249 local stanza, origin = event.stanza, event.origin; |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
250 local query = stanza.tags[1]; |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
251 local node = query.attr.node; |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
252 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
|
253 if not ok then |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
254 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
|
255 end |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
256 |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
257 local reply = st.reply(stanza) |
3949
fc4ff6db1e57
mod_pubsub: Include node in disco#items reply
Matthew Wild <mwild1@gmail.com>
parents:
3946
diff
changeset
|
258 :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
|
259 |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
260 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
|
261 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
|
262 end |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
263 |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
264 return origin.send(reply); |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
265 end |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
266 |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
267 |
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
268 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
|
269 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
|
270 return handle_disco_items_on_node(event); |
aa245e43b21e
mod_pubsub: Handle disco#items on nodes
Matthew Wild <mwild1@gmail.com>
parents:
3919
diff
changeset
|
271 end |
3760
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
272 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
|
273 if not ok then |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
274 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
|
275 else |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
276 local reply = st.reply(event.stanza) |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
277 :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
|
278 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
|
279 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
|
280 end |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
281 event.origin.send(reply); |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
282 end |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
283 return true; |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
284 end); |
3bfb65496773
mod_pubsub: Handle disco#info and disco#items
Matthew Wild <mwild1@gmail.com>
parents:
3700
diff
changeset
|
285 |
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
|
286 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
|
287 local function get_affiliation(jid) |
3919
e288372dd19f
mod_pubsub: Use bare JID in get_affiliation
Matthew Wild <mwild1@gmail.com>
parents:
3918
diff
changeset
|
288 local bare_jid = jid_bare(jid); |
e288372dd19f
mod_pubsub: Use bare JID in get_affiliation
Matthew Wild <mwild1@gmail.com>
parents:
3918
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 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
|
293 |
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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 |
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
|
300 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
|
301 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
|
302 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
|
303 |
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
|
304 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
|
305 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
|
306 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
|
307 |
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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 |
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
|
316 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
|
317 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
|
318 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
|
319 get_subscriptions = true; |
3913
e748d29b18d6
mod_pubsub: Fix capabilities table from some debugging
Matthew Wild <mwild1@gmail.com>
parents:
3912
diff
changeset
|
320 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
|
321 |
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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 |
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
|
327 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
|
328 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
|
329 |
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
|
330 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
|
331 }; |
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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 |
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 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
|
339 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
|
340 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
|
341 get_subscriptions = true; |
3913
e748d29b18d6
mod_pubsub: Fix capabilities table from some debugging
Matthew Wild <mwild1@gmail.com>
parents:
3912
diff
changeset
|
342 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
|
343 |
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
|
344 |
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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 |
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
|
350 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
|
351 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
|
352 |
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
|
353 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
|
354 }; |
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
|
355 }; |
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 |
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
|
357 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
|
358 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
|
359 |
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 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
|
361 get_affiliation = get_affiliation; |
3935
2733b56f23b0
mod_pubsub: Set normalize_jid instead of jids_equal
Matthew Wild <mwild1@gmail.com>
parents:
3933
diff
changeset
|
362 |
2733b56f23b0
mod_pubsub: Set normalize_jid instead of jids_equal
Matthew Wild <mwild1@gmail.com>
parents:
3933
diff
changeset
|
363 normalize_jid = jid_bare; |
4246
d0767040236f
mod_pubsub: Support for setting a disco name
Marco Cirillo <maranda@lightwitch.org>
parents:
4225
diff
changeset
|
364 })); |