Comparison

plugins/mod_pubsub.lua @ 5320:518d864b2ab8

mod_pubsub, util.pubsub: Add delete action
author Kim Alvefur <zash@zash.se>
date Thu, 31 Jan 2013 18:41:01 +0100
parent 5318:989acb4ad1de
child 5419:e28fca8faf62
comparison
equal deleted inserted replaced
5319:d20861bf900b 5320:518d864b2ab8
117 end 117 end
118 end 118 end
119 return origin.send(reply); 119 return origin.send(reply);
120 end 120 end
121 121
122 function handlers.set_delete(origin, stanza, delete)
123 local node = delete.attr.node;
124
125 local reply, notifier;
126 if not node then
127 return origin.send(pubsub_error_reply(stanza, "nodeid-required"));
128 end
129 local ok, ret = service:delete(node, stanza.attr.from);
130 if ok then
131 reply = st.reply(stanza);
132 else
133 reply = pubsub_error_reply(stanza, ret);
134 end
135 return origin.send(reply);
136 end
137
122 function handlers.set_subscribe(origin, stanza, subscribe) 138 function handlers.set_subscribe(origin, stanza, subscribe)
123 local node, jid = subscribe.attr.node, subscribe.attr.jid; 139 local node, jid = subscribe.attr.node, subscribe.attr.jid;
124 if not (node and jid) then 140 if not (node and jid) then
125 return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); 141 return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid"));
126 end 142 end
256 local feature_map = { 272 local feature_map = {
257 create = { "create-nodes", "instant-nodes", "item-ids" }; 273 create = { "create-nodes", "instant-nodes", "item-ids" };
258 retract = { "delete-items", "retract-items" }; 274 retract = { "delete-items", "retract-items" };
259 purge = { "purge-nodes" }; 275 purge = { "purge-nodes" };
260 publish = { "publish", autocreate_on_publish and "auto-create" }; 276 publish = { "publish", autocreate_on_publish and "auto-create" };
277 delete = { "delete-nodes" };
261 get_items = { "retrieve-items" }; 278 get_items = { "retrieve-items" };
262 add_subscription = { "subscribe" }; 279 add_subscription = { "subscribe" };
263 get_subscriptions = { "retrieve-subscriptions" }; 280 get_subscriptions = { "retrieve-subscriptions" };
264 }; 281 };
265 282
416 }; 433 };
417 owner = { 434 owner = {
418 create = true; 435 create = true;
419 publish = true; 436 publish = true;
420 retract = true; 437 retract = true;
438 delete = true;
421 get_nodes = true; 439 get_nodes = true;
422 440
423 subscribe = true; 441 subscribe = true;
424 unsubscribe = true; 442 unsubscribe = true;
425 get_subscription = true; 443 get_subscription = true;