Software /
code /
prosody
Comparison
util/pubsub.lua @ 8813:2c55fccb0c0c
util.pubsub: Pass node and service objects to broadcaster to allow eg config access
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 May 2018 00:35:00 +0200 |
parent | 8810:9f8a746f99c1 |
child | 8816:0f9d5cfa84f9 |
comparison
equal
deleted
inserted
replaced
8812:3d7fceaff230 | 8813:2c55fccb0c0c |
---|---|
287 if self.data[node] and self.data[node].clear then | 287 if self.data[node] and self.data[node].clear then |
288 self.data[node]:clear(); | 288 self.data[node]:clear(); |
289 end | 289 end |
290 self.data[node] = nil; | 290 self.data[node] = nil; |
291 self.events.fire_event("node-deleted", { node = node, actor = actor }); | 291 self.events.fire_event("node-deleted", { node = node, actor = actor }); |
292 self.config.broadcaster("delete", node, node_obj.subscribers); | 292 self.config.broadcaster("delete", node, node_obj.subscribers, nil, actor, node_obj, self); |
293 return true; | 293 return true; |
294 end | 294 end |
295 | 295 |
296 function service:publish(node, actor, id, item) | 296 function service:publish(node, actor, id, item) |
297 -- Access checking | 297 -- Access checking |
318 if not ok then | 318 if not ok then |
319 return nil, "internal-server-error"; | 319 return nil, "internal-server-error"; |
320 end | 320 end |
321 if type(ok) == "string" then id = ok; end | 321 if type(ok) == "string" then id = ok; end |
322 self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item }); | 322 self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item }); |
323 self.config.broadcaster("items", node, node_obj.subscribers, item, actor); | 323 self.config.broadcaster("items", node, node_obj.subscribers, item, actor, node_obj, self); |
324 return true; | 324 return true; |
325 end | 325 end |
326 | 326 |
327 function service:retract(node, actor, id, retract) | 327 function service:retract(node, actor, id, retract) |
328 -- Access checking | 328 -- Access checking |
338 if not ok then | 338 if not ok then |
339 return nil, "internal-server-error"; | 339 return nil, "internal-server-error"; |
340 end | 340 end |
341 self.events.fire_event("item-retracted", { node = node, actor = actor, id = id }); | 341 self.events.fire_event("item-retracted", { node = node, actor = actor, id = id }); |
342 if retract then | 342 if retract then |
343 self.config.broadcaster("items", node, node_obj.subscribers, retract); | 343 self.config.broadcaster("items", node, node_obj.subscribers, retract, actor, node_obj, self); |
344 end | 344 end |
345 return true | 345 return true |
346 end | 346 end |
347 | 347 |
348 function service:purge(node, actor, notify) | 348 function service:purge(node, actor, notify) |
360 else | 360 else |
361 self.data[node] = self.config.itemstore(self.nodes[node].config, node); | 361 self.data[node] = self.config.itemstore(self.nodes[node].config, node); |
362 end | 362 end |
363 self.events.fire_event("node-purged", { node = node, actor = actor }); | 363 self.events.fire_event("node-purged", { node = node, actor = actor }); |
364 if notify then | 364 if notify then |
365 self.config.broadcaster("purge", node, node_obj.subscribers); | 365 self.config.broadcaster("purge", node, node_obj.subscribers, nil, actor, node_obj, self); |
366 end | 366 end |
367 return true | 367 return true |
368 end | 368 end |
369 | 369 |
370 function service:get_items(node, actor, id) | 370 function service:get_items(node, actor, id) |