Comparison

util/pubsub.lua @ 8954:3b6095686498

util.pubsub: Persistence on affiliation change
author Kim Alvefur <zash@zash.se>
date Sun, 01 Jul 2018 04:33:15 +0200
parent 8952:15bb54f96dd1
child 8955:ca6a09cf2829
comparison
equal deleted inserted replaced
8953:19cbe80df9c8 8954:3b6095686498
119 local node_obj = self.nodes[node]; 119 local node_obj = self.nodes[node];
120 if not node_obj then 120 if not node_obj then
121 return false, "item-not-found"; 121 return false, "item-not-found";
122 end 122 end
123 jid = self.config.normalize_jid(jid); 123 jid = self.config.normalize_jid(jid);
124 local old_affiliation = node_obj.affiliations[jid];
124 node_obj.affiliations[jid] = affiliation; 125 node_obj.affiliations[jid] = affiliation;
126
127 if self.config.nodestore then
128 local ok, err = save_node_to_store(self, node_obj);
129 if not ok then
130 node_obj.affiliations[jid] = old_affiliation;
131 return ok, "internal-server-error";
132 end
133 end
134
125 local _, jid_sub = self:get_subscription(node, true, jid); 135 local _, jid_sub = self:get_subscription(node, true, jid);
126 if not jid_sub and not self:may(node, jid, "be_unsubscribed") then 136 if not jid_sub and not self:may(node, jid, "be_unsubscribed") then
127 local ok, err = self:add_subscription(node, true, jid); 137 local ok, err = self:add_subscription(node, true, jid);
128 if not ok then 138 if not ok then
129 return ok, err; 139 return ok, err;