Comparison

plugins/mod_pep_plus.lua @ 8332:e89b57d0d80a

mod_pep_plus: Advertise additional features not covered by inspection of pubsub service methods
author Kim Alvefur <zash@zash.se>
date Tue, 17 Oct 2017 05:30:09 +0200
parent 8331:8df0eaa564f0
child 8333:2abbb01cd756
comparison
equal deleted inserted replaced
8331:8df0eaa564f0 8332:e89b57d0d80a
418 418
419 module:hook("account-disco-info", function(event) 419 module:hook("account-disco-info", function(event)
420 local origin, reply = event.origin, event.reply; 420 local origin, reply = event.origin, event.reply;
421 421
422 reply:tag('identity', {category='pubsub', type='pep'}):up(); 422 reply:tag('identity', {category='pubsub', type='pep'}):up();
423 reply:tag('feature', {var=xmlns_pubsub}):up();
423 424
424 local username = jid_split(reply.attr.from) or origin.username; 425 local username = jid_split(reply.attr.from) or origin.username;
425 local service = get_pep_service(username); 426 local service = get_pep_service(username);
426 427
427 local feature_map = { 428 local feature_map = {
449 for affiliation in pairs(service.config.capabilities) do 450 for affiliation in pairs(service.config.capabilities) do
450 if affiliation ~= "none" and affiliation ~= "owner" then 451 if affiliation ~= "none" and affiliation ~= "owner" then
451 reply:tag('feature', {var=xmlns_pubsub.."#"..affiliation.."-affiliation"}):up(); 452 reply:tag('feature', {var=xmlns_pubsub.."#"..affiliation.."-affiliation"}):up();
452 end 453 end
453 end 454 end
455
456 -- Features not covered by the above
457 local more_features = {
458 "access-presence",
459 "auto-subscribe",
460 "filtered-notifications",
461 "last-published",
462 "persistent-items",
463 "presence-notifications",
464 "presence-subscribe",
465 };
466 for _, feature in ipairs(more_features) do
467 reply:tag('feature', {var=xmlns_pubsub.."#"..feature}):up();
468 end
454 end); 469 end);
455 470
456 module:hook("account-disco-items-node", function(event) 471 module:hook("account-disco-items-node", function(event)
457 local reply, stanza, origin = event.reply, event.stanza, event.origin; 472 local reply, stanza, origin = event.reply, event.stanza, event.origin;
458 local node = event.node; 473 local node = event.node;