Mercurial > prosody-hg
comparison util/pubsub.lua @ 5312:fdcd2ac7c22d
mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Fri, 25 Jan 2013 01:32:14 +0100 |
| parents | 391b72fede9f |
| children | abf1a926d0da |
comparison
equal
deleted
inserted
replaced
| 5311:86fe6e2fa5ae | 5312:fdcd2ac7c22d |
|---|---|
| 243 end | 243 end |
| 244 node_obj = self.nodes[node]; | 244 node_obj = self.nodes[node]; |
| 245 end | 245 end |
| 246 node_obj.data[id] = item; | 246 node_obj.data[id] = item; |
| 247 self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item }); | 247 self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item }); |
| 248 self.config.broadcaster(node, node_obj.subscribers, item); | 248 self.config.broadcaster("items", node, node_obj.subscribers, item); |
| 249 return true; | 249 return true; |
| 250 end | 250 end |
| 251 | 251 |
| 252 function service:retract(node, actor, id, retract) | 252 function service:retract(node, actor, id, retract) |
| 253 -- Access checking | 253 -- Access checking |
| 257 -- | 257 -- |
| 258 local node_obj = self.nodes[node]; | 258 local node_obj = self.nodes[node]; |
| 259 if (not node_obj) or (not node_obj.data[id]) then | 259 if (not node_obj) or (not node_obj.data[id]) then |
| 260 return false, "item-not-found"; | 260 return false, "item-not-found"; |
| 261 end | 261 end |
| 262 if id then | 262 node_obj.data[id] = nil; |
| 263 node_obj.data[id] = nil; | |
| 264 else | |
| 265 node_obj.data = {}; -- Purge | |
| 266 end | |
| 267 if retract then | 263 if retract then |
| 268 self.config.broadcaster(node, node_obj.subscribers, retract); | 264 self.config.broadcaster("items", node, node_obj.subscribers, retract); |
| 269 end | 265 end |
| 270 return true | 266 return true |
| 271 end | 267 end |
| 272 | 268 |
| 273 function service:purge(node, actor, purge) | 269 function service:purge(node, actor, notify) |
| 274 return self:retract(node, actor, nil, purge); | 270 -- Access checking |
| 271 if not self:may(node, actor, "retract") then | |
| 272 return false, "forbidden"; | |
| 273 end | |
| 274 -- | |
| 275 local node_obj = self.nodes[node]; | |
| 276 if not node_obj then | |
| 277 return false, "item-not-found"; | |
| 278 end | |
| 279 node_obj.data = {}; -- Purge | |
| 280 if notify then | |
| 281 self.config.broadcaster("purge", node, node_obj.subscribers); | |
| 282 end | |
| 283 return true | |
| 275 end | 284 end |
| 276 | 285 |
| 277 function service:get_items(node, actor, id) | 286 function service:get_items(node, actor, id) |
| 278 -- Access checking | 287 -- Access checking |
| 279 if not self:may(node, actor, "get_items") then | 288 if not self:may(node, actor, "get_items") then |
