Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 8979:6897b2e18bdf

mod_pubsub: Support configurable title and description fields
author Kim Alvefur <zash@zash.se>
date Fri, 06 Jul 2018 16:04:53 +0200
parent 8978:9d6c0c11e383
child 8980:4d2738b99b07
comparison
equal deleted inserted replaced
8978:9d6c0c11e383 8979:6897b2e18bdf
44 name = "FORM_TYPE"; 44 name = "FORM_TYPE";
45 value = "http://jabber.org/protocol/pubsub#node_config"; 45 value = "http://jabber.org/protocol/pubsub#node_config";
46 }; 46 };
47 { 47 {
48 type = "text-single"; 48 type = "text-single";
49 name = "pubsub#title";
50 label = "Title";
51 };
52 {
53 type = "text-single";
54 name = "pubsub#description";
55 label = "Description";
56 };
57 {
58 type = "text-single";
49 name = "pubsub#max_items"; 59 name = "pubsub#max_items";
50 label = "Max # of items to persist"; 60 label = "Max # of items to persist";
51 }; 61 };
52 { 62 {
53 type = "boolean"; 63 type = "boolean";
397 return true; 407 return true;
398 end 408 end
399 409
400 local node_config = node_obj.config; 410 local node_config = node_obj.config;
401 local pubsub_form_data = { 411 local pubsub_form_data = {
412 ["pubsub#title"] = node_config["title"];
413 ["pubsub#description"] = node_config["description"];
402 ["pubsub#max_items"] = tostring(node_config["max_items"]); 414 ["pubsub#max_items"] = tostring(node_config["max_items"]);
403 ["pubsub#persist_items"] = node_config["persist_items"]; 415 ["pubsub#persist_items"] = node_config["persist_items"];
404 ["pubsub#notification_type"] = node_config["notification_type"]; 416 ["pubsub#notification_type"] = node_config["notification_type"];
405 ["pubsub#include_body"] = node_config["include_body"]; 417 ["pubsub#include_body"] = node_config["include_body"];
406 } 418 }
431 if not form_data then 443 if not form_data then
432 origin.send(st.error_reply(stanza, "modify", "bad-request", err)); 444 origin.send(st.error_reply(stanza, "modify", "bad-request", err));
433 return true; 445 return true;
434 end 446 end
435 local new_config = { 447 local new_config = {
448 ["title"] = form_data["pubsub#title"];
449 ["description"] = form_data["pubsub#description"];
436 ["max_items"] = tonumber(form_data["pubsub#max_items"]); 450 ["max_items"] = tonumber(form_data["pubsub#max_items"]);
437 ["persist_items"] = form_data["pubsub#persist_items"]; 451 ["persist_items"] = form_data["pubsub#persist_items"];
438 ["notification_type"] = form_data["pubsub#notification_type"]; 452 ["notification_type"] = form_data["pubsub#notification_type"];
439 ["include_body"] = form_data["pubsub#include_body"]; 453 ["include_body"] = form_data["pubsub#include_body"];
440 }; 454 };