plugins/mod_pubsub/pubsub.lib.lua
changeset 8339 587305c0ff85
parent 8337 036e46d12b78
child 8340 dc4ea43ac463
equal deleted inserted replaced
8338:9db72349095f 8339:587305c0ff85
    58 	local pubsub_tag = stanza.tags[1];
    58 	local pubsub_tag = stanza.tags[1];
    59 	local action = pubsub_tag.tags[1];
    59 	local action = pubsub_tag.tags[1];
    60 	if not action then
    60 	if not action then
    61 		return origin.send(st.error_reply(stanza, "cancel", "bad-request"));
    61 		return origin.send(st.error_reply(stanza, "cancel", "bad-request"));
    62 	end
    62 	end
    63 	local handler = handlers[stanza.attr.type.."_"..action.name];
    63 	local prefix = "";
       
    64 	if pubsub_tag.attr.xmlns == xmlns_pubsub_owner then
       
    65 		prefix = "owner_";
       
    66 	end
       
    67 	local handler = handlers[prefix..stanza.attr.type.."_"..action.name];
    64 	if handler then
    68 	if handler then
    65 		handler(origin, stanza, action, service);
    69 		handler(origin, stanza, action, service);
    66 		return true;
    70 		return true;
    67 	end
    71 	end
    68 end
    72 end
   140 	end
   144 	end
   141 	origin.send(reply);
   145 	origin.send(reply);
   142 	return true;
   146 	return true;
   143 end
   147 end
   144 
   148 
   145 function handlers.set_delete(origin, stanza, delete, service)
   149 function handlers.owner_set_delete(origin, stanza, delete, service)
   146 	local node = delete.attr.node;
   150 	local node = delete.attr.node;
   147 
   151 
   148 	local reply;
   152 	local reply;
   149 	if not node then
   153 	if not node then
   150 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   154 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   258 	end
   262 	end
   259 	origin.send(reply);
   263 	origin.send(reply);
   260 	return true;
   264 	return true;
   261 end
   265 end
   262 
   266 
   263 function handlers.set_purge(origin, stanza, purge, service)
   267 function handlers.owner_set_purge(origin, stanza, purge, service)
   264 	local node, notify = purge.attr.node, purge.attr.notify;
   268 	local node, notify = purge.attr.node, purge.attr.notify;
   265 	notify = (notify == "1") or (notify == "true");
   269 	notify = (notify == "1") or (notify == "true");
   266 	local reply;
   270 	local reply;
   267 	if not node then
   271 	if not node then
   268 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   272 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   276 	end
   280 	end
   277 	origin.send(reply);
   281 	origin.send(reply);
   278 	return true;
   282 	return true;
   279 end
   283 end
   280 
   284 
   281 function handlers.get_configure(origin, stanza, config, service)
   285 function handlers.owner_get_configure(origin, stanza, config, service)
   282 	local node = config.attr.node;
   286 	local node = config.attr.node;
   283 	if not node then
   287 	if not node then
   284 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   288 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   285 		return true;
   289 		return true;
   286 	end
   290 	end
   307 				:add_child(node_config_form:form(pubsub_form_data));
   311 				:add_child(node_config_form:form(pubsub_form_data));
   308 	origin.send(reply);
   312 	origin.send(reply);
   309 	return true;
   313 	return true;
   310 end
   314 end
   311 
   315 
   312 function handlers.set_configure(origin, stanza, config, service)
   316 function handlers.owner_set_configure(origin, stanza, config, service)
   313 	local node = config.attr.node;
   317 	local node = config.attr.node;
   314 	if not node then
   318 	if not node then
   315 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   319 		origin.send(pubsub_error_reply(stanza, "nodeid-required"));
   316 		return true;
   320 		return true;
   317 	end
   321 	end
   340 	end
   344 	end
   341 	origin.send(st.reply(stanza));
   345 	origin.send(st.reply(stanza));
   342 	return true;
   346 	return true;
   343 end
   347 end
   344 
   348 
   345 function handlers.get_default(origin, stanza, default, service)
   349 function handlers.owner_get_default(origin, stanza, default, service) -- luacheck: ignore 212/default
   346 	local pubsub_form_data = {
   350 	local pubsub_form_data = {
   347 		["pubsub#max_items"] = tostring(service.node_defaults["max_items"]);
   351 		["pubsub#max_items"] = tostring(service.node_defaults["max_items"]);
   348 		["pubsub#persist_items"] = service.node_defaults["persist_items"]
   352 		["pubsub#persist_items"] = service.node_defaults["persist_items"]
   349 	}
   353 	}
   350 	local reply = st.reply(stanza)
   354 	local reply = st.reply(stanza)