Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 9180:cc68cb03f85e

mod_pubsub: Add payload type metadata field
author Kim Alvefur <zash@zash.se>
date Mon, 13 Aug 2018 20:44:01 +0200
parent 9137:4803d2feeecb
child 9182:ec48c02ded0c
comparison
equal deleted inserted replaced
9179:82fad995a149 9180:cc68cb03f85e
60 name = "pubsub#description"; 60 name = "pubsub#description";
61 label = "Description"; 61 label = "Description";
62 }; 62 };
63 { 63 {
64 type = "text-single"; 64 type = "text-single";
65 name = "pubsub#type";
66 label = "The type of node data, usually specified by the namespace of the payload (if any)";
67 };
68 {
69 type = "text-single";
65 name = "pubsub#max_items"; 70 name = "pubsub#max_items";
66 label = "Max # of items to persist"; 71 label = "Max # of items to persist";
67 }; 72 };
68 { 73 {
69 type = "boolean"; 74 type = "boolean";
128 }; 133 };
129 { 134 {
130 type = "text-single"; 135 type = "text-single";
131 name = "pubsub#description"; 136 name = "pubsub#description";
132 }; 137 };
138 {
139 type = "text-single";
140 name = "pubsub#type";
141 };
133 }; 142 };
134 143
135 local config_field_map = { 144 local config_field_map = {
136 title = "pubsub#title"; 145 title = "pubsub#title";
137 description = "pubsub#description"; 146 description = "pubsub#description";
147 payload_type = "pubsub#type";
138 max_items = "pubsub#max_items"; 148 max_items = "pubsub#max_items";
139 persist_items = "pubsub#persist_items"; 149 persist_items = "pubsub#persist_items";
140 notification_type = "pubsub#notification_type"; 150 notification_type = "pubsub#notification_type";
141 access_model = "pubsub#access_model"; 151 access_model = "pubsub#access_model";
142 publish_model = "pubsub#publish_model"; 152 publish_model = "pubsub#publish_model";
147 -- util.pubsub is meant to be agnostic to XEP-0060 157 -- util.pubsub is meant to be agnostic to XEP-0060
148 local function config_to_xep0060(node_config) 158 local function config_to_xep0060(node_config)
149 return { 159 return {
150 ["pubsub#title"] = node_config["title"]; 160 ["pubsub#title"] = node_config["title"];
151 ["pubsub#description"] = node_config["description"]; 161 ["pubsub#description"] = node_config["description"];
162 ["pubsub#type"] = node_config["payload_type"];
152 ["pubsub#max_items"] = tostring(node_config["max_items"]); 163 ["pubsub#max_items"] = tostring(node_config["max_items"]);
153 ["pubsub#persist_items"] = node_config["persist_items"]; 164 ["pubsub#persist_items"] = node_config["persist_items"];
154 ["pubsub#notification_type"] = node_config["notification_type"]; 165 ["pubsub#notification_type"] = node_config["notification_type"];
155 ["pubsub#access_model"] = node_config["access_model"]; 166 ["pubsub#access_model"] = node_config["access_model"];
156 ["pubsub#publish_model"] = node_config["publish_model"]; 167 ["pubsub#publish_model"] = node_config["publish_model"];
257 reply:tag("identity", { category = "pubsub", type = "leaf" }):up(); 268 reply:tag("identity", { category = "pubsub", type = "leaf" }):up();
258 if node_obj.config then 269 if node_obj.config then
259 reply:add_child(node_metadata_form:form({ 270 reply:add_child(node_metadata_form:form({
260 ["pubsub#title"] = node_obj.config.title; 271 ["pubsub#title"] = node_obj.config.title;
261 ["pubsub#description"] = node_obj.config.description; 272 ["pubsub#description"] = node_obj.config.description;
273 ["pubsub#type"] = node_obj.config.payload_type;
262 }, "result")); 274 }, "result"));
263 end 275 end
264 end 276 end
265 277
266 function _M.handle_disco_items_node(event, service) 278 function _M.handle_disco_items_node(event, service)