Software / code / prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 9033:f1b6efd5b379
mod_pubsub: Add support for modifying subscriptions
https://xmpp.org/extensions/xep-0060.html#owner-subscriptions-modify
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 13 Jul 2018 04:52:43 +0200 |
| parent | 9032:029e1e18d65c |
| child | 9037:e3c8274427d3 |
comparison
equal
deleted
inserted
replaced
| 9032:029e1e18d65c | 9033:f1b6efd5b379 |
|---|---|
| 265 end | 265 end |
| 266 origin.send(reply); | 266 origin.send(reply); |
| 267 return true; | 267 return true; |
| 268 end | 268 end |
| 269 | 269 |
| 270 function handlers.owner_set_subscriptions(origin, stanza, subscriptions, service) | |
| 271 local node = subscriptions.attr.node; | |
| 272 if not node then | |
| 273 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | |
| 274 return true; | |
| 275 end | |
| 276 if not service:may(node, stanza.attr.from, "subscribe_other") then | |
| 277 origin.send(pubsub_error_reply(stanza, "forbidden")); | |
| 278 return true; | |
| 279 end | |
| 280 | |
| 281 local node_obj = service.nodes[node]; | |
| 282 if not node_obj then | |
| 283 origin.send(pubsub_error_reply(stanza, "item-not-found")); | |
| 284 return true; | |
| 285 end | |
| 286 | |
| 287 for subscription_tag in subscriptions:childtags("subscription") do | |
| 288 if subscription_tag.attr.subscription == 'subscribed' then | |
| 289 local ok, err = service:add_subscription(node, stanza.attr.from, subscription_tag.attr.jid); | |
| 290 if not ok then | |
| 291 origin.send(pubsub_error_reply(stanza, err)); | |
| 292 return true; | |
| 293 end | |
| 294 elseif subscription_tag.attr.subscription == 'none' then | |
| 295 local ok, err = service:remove_subscription(node, stanza.attr.from, subscription_tag.attr.jid); | |
| 296 if not ok then | |
| 297 origin.send(pubsub_error_reply(stanza, err)); | |
| 298 return true; | |
| 299 end | |
| 300 end | |
| 301 end | |
| 302 | |
| 303 local reply = st.reply(stanza); | |
| 304 origin.send(reply); | |
| 305 return true; | |
| 306 end | |
| 307 | |
| 270 function handlers.set_create(origin, stanza, create, service) | 308 function handlers.set_create(origin, stanza, create, service) |
| 271 local node = create.attr.node; | 309 local node = create.attr.node; |
| 272 local ok, ret, reply; | 310 local ok, ret, reply; |
| 273 local config; | 311 local config; |
| 274 local configure = stanza.tags[1]:get_child("configure"); | 312 local configure = stanza.tags[1]:get_child("configure"); |