Comparison

util/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 5315:abf1a926d0da
child 5628:ba5c2f6b799e
comparison
equal deleted inserted replaced
5319:d20861bf900b 5320:518d864b2ab8
222 local ok, err = self:set_affiliation(node, true, actor, "owner"); 222 local ok, err = self:set_affiliation(node, true, actor, "owner");
223 if not ok then 223 if not ok then
224 self.nodes[node] = nil; 224 self.nodes[node] = nil;
225 end 225 end
226 return ok, err; 226 return ok, err;
227 end
228
229 function service:delete(node, actor)
230 -- Access checking
231 if not self:may(node, actor, "delete") then
232 return false, "forbidden";
233 end
234 --
235 local node_obj = self.nodes[node];
236 self.nodes[node] = nil;
237 self.config.broadcaster("delete", node, node_obj.subscribers);
238 return true;
227 end 239 end
228 240
229 function service:publish(node, actor, id, item) 241 function service:publish(node, actor, id, item)
230 -- Access checking 242 -- Access checking
231 if not self:may(node, actor, "publish") then 243 if not self:may(node, actor, "publish") then