Software /
code /
prosody
Comparison
plugins/mod_pep_plus.lua @ 8319:57e3ad11f3f6
mod_pep_plus: Advertise pubsub features in disco#info (code adapted from mod_pubsub)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 12 Oct 2017 01:34:32 +0200 |
parent | 8318:d0a7fc7614de |
child | 8320:fe5eaf4ed631 |
comparison
equal
deleted
inserted
replaced
8318:d0a7fc7614de | 8319:57e3ad11f3f6 |
---|---|
407 event.exists = true; | 407 event.exists = true; |
408 reply:tag('identity', {category='pubsub', type='leaf'}):up(); | 408 reply:tag('identity', {category='pubsub', type='leaf'}):up(); |
409 end); | 409 end); |
410 | 410 |
411 module:hook("account-disco-info", function(event) | 411 module:hook("account-disco-info", function(event) |
412 local reply = event.reply; | 412 local origin, reply = event.origin, event.reply; |
413 | |
413 reply:tag('identity', {category='pubsub', type='pep'}):up(); | 414 reply:tag('identity', {category='pubsub', type='pep'}):up(); |
414 reply:tag('feature', {var='http://jabber.org/protocol/pubsub#publish'}):up(); | 415 |
416 local username = jid_split(reply.attr.from) or origin.username; | |
417 local service = get_pep_service(username); | |
418 | |
419 local feature_map = { | |
420 create = { "create-nodes", "instant-nodes", "item-ids" }; | |
421 retract = { "delete-items", "retract-items" }; | |
422 purge = { "purge-nodes" }; | |
423 publish = { "publish", service.config.autocreate_on_publish and "auto-create" }; | |
424 delete = { "delete-nodes" }; | |
425 get_items = { "retrieve-items" }; | |
426 add_subscription = { "subscribe" }; | |
427 get_subscriptions = { "retrieve-subscriptions" }; | |
428 set_configure = { "config-node" }; | |
429 get_default = { "retrieve-default" }; | |
430 }; | |
431 | |
432 for method, features in pairs(feature_map) do | |
433 if service[method] then | |
434 for _, feature in ipairs(features) do | |
435 if feature then | |
436 reply:tag('feature', {var=xmlns_pubsub.."#"..feature}):up(); | |
437 end | |
438 end | |
439 end | |
440 end | |
441 for affiliation in pairs(service.config.capabilities) do | |
442 if affiliation ~= "none" and affiliation ~= "owner" then | |
443 reply:tag('feature', {var=xmlns_pubsub.."#"..affiliation.."-affiliation"}):up(); | |
444 end | |
445 end | |
415 end); | 446 end); |
416 | 447 |
417 module:hook("account-disco-items-node", function(event) | 448 module:hook("account-disco-items-node", function(event) |
418 local reply, stanza, origin = event.reply, event.stanza, event.origin; | 449 local reply, stanza, origin = event.reply, event.stanza, event.origin; |
419 local node = event.node; | 450 local node = event.node; |