Software /
code /
prosody
Comparison
util/pubsub.lua @ 8297:ac5c90230c2c
util.pubsub: Clear data store if it supports being cleared, otherwise fall back to creating a new one
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Oct 2017 01:27:04 +0200 |
parent | 8220:a1b0fa38fca7 |
child | 8312:6fd36e73082b |
comparison
equal
deleted
inserted
replaced
8296:e23328adca25 | 8297:ac5c90230c2c |
---|---|
310 -- | 310 -- |
311 local node_obj = self.nodes[node]; | 311 local node_obj = self.nodes[node]; |
312 if not node_obj then | 312 if not node_obj then |
313 return false, "item-not-found"; | 313 return false, "item-not-found"; |
314 end | 314 end |
315 self.data[node] = self.config.itemstore(self.nodes[node].config, node); | 315 if self.data[node] and self.data[node].clear then |
316 self.data[node]:clear() | |
317 else | |
318 self.data[node] = self.config.itemstore(self.nodes[node].config, node); | |
319 end | |
316 self.events.fire_event("node-purged", { node = node, actor = actor }); | 320 self.events.fire_event("node-purged", { node = node, actor = actor }); |
317 if notify then | 321 if notify then |
318 self.config.broadcaster("purge", node, node_obj.subscribers); | 322 self.config.broadcaster("purge", node, node_obj.subscribers); |
319 end | 323 end |
320 return true | 324 return true |