Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 9116:9f36f5c14545

mod_pubsub: Rename variable subscription options form to improve readability "options_form" ... options for what?
author Kim Alvefur <zash@zash.se>
date Sun, 05 Aug 2018 02:01:58 +0200
parent 9115:fddebfaae7d9
child 9120:01fc8ba0a7fa
child 9123:5d5aa1c4fe34
comparison
equal deleted inserted replaced
9115:fddebfaae7d9 9116:9f36f5c14545
93 { label = "Messages of type headline", value = "headline", default = true }, 93 { label = "Messages of type headline", value = "headline", default = true },
94 }; 94 };
95 }; 95 };
96 }; 96 };
97 97
98 local options_form = dataform { 98 local subscribe_options_form = dataform {
99 { 99 {
100 type = "hidden"; 100 type = "hidden";
101 name = "FORM_TYPE"; 101 name = "FORM_TYPE";
102 value = "http://jabber.org/protocol/pubsub#subscribe_options"; 102 value = "http://jabber.org/protocol/pubsub#subscribe_options";
103 }; 103 };
451 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); 451 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid"));
452 return true; 452 return true;
453 end 453 end
454 local options_tag, options = stanza.tags[1]:get_child("options"), nil; 454 local options_tag, options = stanza.tags[1]:get_child("options"), nil;
455 if options_tag then 455 if options_tag then
456 options = options_form:data(options_tag.tags[1]); 456 options = subscribe_options_form:data(options_tag.tags[1]);
457 end 457 end
458 local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options); 458 local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options);
459 local reply; 459 local reply;
460 if ok then 460 if ok then
461 reply = st.reply(stanza) 461 reply = st.reply(stanza)
506 end 506 end
507 if ret == true then ret = {} end 507 if ret == true then ret = {} end
508 origin.send(st.reply(stanza) 508 origin.send(st.reply(stanza)
509 :tag("pubsub", { xmlns = xmlns_pubsub }) 509 :tag("pubsub", { xmlns = xmlns_pubsub })
510 :tag("options", { node = node, jid = jid }) 510 :tag("options", { node = node, jid = jid })
511 :add_child(options_form:form(ret))); 511 :add_child(subscribe_options_form:form(ret)));
512 return true; 512 return true;
513 end 513 end
514 514
515 function handlers.set_options(origin, stanza, options, service) 515 function handlers.set_options(origin, stanza, options, service)
516 local node, jid = options.attr.node, options.attr.jid; 516 local node, jid = options.attr.node, options.attr.jid;
525 return true; 525 return true;
526 elseif not ret then 526 elseif not ret then
527 origin.send(pubsub_error_reply(stanza, "not-subscribed")); 527 origin.send(pubsub_error_reply(stanza, "not-subscribed"));
528 return true; 528 return true;
529 end 529 end
530 local new_subopts, err = options_form:data(options.tags[1]); 530 local new_subopts, err = subscribe_options_form:data(options.tags[1]);
531 if not new_subopts then 531 if not new_subopts then
532 origin.send(pubsub_error_reply(stanza, ret)); 532 origin.send(pubsub_error_reply(stanza, ret));
533 return true; 533 return true;
534 end 534 end
535 local ok, err = service:add_subscription(node, stanza.attr.from, jid, new_subopts); 535 local ok, err = service:add_subscription(node, stanza.attr.from, jid, new_subopts);