diff options
author | Kim Alvefur <zash@zash.se> | 2018-07-01 04:33:15 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-07-01 04:33:15 +0200 |
commit | 75560d4ebeb910c529fe4b04db2cff097eb01ea2 (patch) | |
tree | 9d29c8879f54296c560f3e1dc59c3d0ec5dc98ee /util | |
parent | 530ceb8a401296d38aa5c38ee150ecb42fb654e6 (diff) | |
download | prosody-75560d4ebeb910c529fe4b04db2cff097eb01ea2.tar.gz prosody-75560d4ebeb910c529fe4b04db2cff097eb01ea2.zip |
util.pubsub: Persistence on affiliation change
Diffstat (limited to 'util')
-rw-r--r-- | util/pubsub.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua index 0f31423d..267c9a3c 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -121,7 +121,17 @@ function service:set_affiliation(node, actor, jid, affiliation) return false, "item-not-found"; end jid = self.config.normalize_jid(jid); + local old_affiliation = node_obj.affiliations[jid]; node_obj.affiliations[jid] = affiliation; + + if self.config.nodestore then + local ok, err = save_node_to_store(self, node_obj); + if not ok then + node_obj.affiliations[jid] = old_affiliation; + return ok, "internal-server-error"; + end + end + local _, jid_sub = self:get_subscription(node, true, jid); if not jid_sub and not self:may(node, jid, "be_unsubscribed") then local ok, err = self:add_subscription(node, true, jid); |