Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 9040:e993fad0cc62

mod_pubsub: Add support for retrieving subscription options
author Kim Alvefur <zash@zash.se>
date Sat, 14 Jul 2018 19:35:26 +0200
parent 9039:0124e5ec1556
child 9041:b3bc742ee188
comparison
equal deleted inserted replaced
9039:0124e5ec1556 9040:e993fad0cc62
431 end 431 end
432 origin.send(reply); 432 origin.send(reply);
433 return true; 433 return true;
434 end 434 end
435 435
436 function handlers.get_options(origin, stanza, options, service)
437 local node, jid = options.attr.node, options.attr.jid;
438 jid = jid_prep(jid);
439 if not (node and jid) then
440 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid"));
441 return true;
442 end
443 local ok, ret = service:get_subscription(node, stanza.attr.from, jid);
444 if not ok then
445 origin.send(pubsub_error_reply(stanza, "not-subscribed"));
446 return true;
447 end
448 if ret == true then ret = {} end
449 origin.send(st.reply(stanza)
450 :tag("pubsub", { xmlns = xmlns_pubsub })
451 :tag("options", { node = node, jid = jid })
452 :add_child(options_form:form(ret)));
453 return true;
454 end
455
436 function handlers.set_publish(origin, stanza, publish, service) 456 function handlers.set_publish(origin, stanza, publish, service)
437 local node = publish.attr.node; 457 local node = publish.attr.node;
438 if not node then 458 if not node then
439 origin.send(pubsub_error_reply(stanza, "nodeid-required")); 459 origin.send(pubsub_error_reply(stanza, "nodeid-required"));
440 return true; 460 return true;