--- a/plugins/muc/muc.lib.lua Sat Sep 01 00:45:51 2018 +0200
+++ b/plugins/muc/muc.lib.lua Mon Sep 03 12:18:13 2018 +0100
@@ -1198,7 +1198,8 @@
end
end
-function room_mt:set_affiliation(actor, jid, affiliation, reason)
+function room_mt:set_affiliation(actor, jid, affiliation, reason, data)
+ module:log("debug", "data is %s", tostring(data));
if not actor then return nil, "modify", "not-acceptable"; end;
local node, host, resource = jid_split(jid);
@@ -1240,6 +1241,13 @@
-- Set in 'database'
self._affiliations[jid] = affiliation;
+ if not affiliation or data == false or (data ~= nil and next(data) == nil) then
+ module:log("debug", "Clearing affiliation data for %s", jid);
+ self._affiliation_data[jid] = nil;
+ elseif data then
+ module:log("debug", "Updating affiliation data for %s", jid);
+ self._affiliation_data[jid] = data;
+ end
-- Update roles
local role = self:get_default_role(affiliation);
@@ -1297,6 +1305,7 @@
affiliation = affiliation or "none";
reason = reason;
previous_affiliation = target_affiliation;
+ data = data and data or nil; -- coerce false to nil
in_room = next(occupants_updated) ~= nil;
});
@@ -1369,6 +1378,7 @@
_occupants = {};
_data = config or {};
_affiliations = {};
+ _affiliation_data = {};
}, room_mt);
end
@@ -1389,6 +1399,7 @@
jid = self.jid;
_data = self._data;
_affiliations = self._affiliations;
+ _affiliation_data = self._affiliation_data;
};
end
if live then
@@ -1426,6 +1437,8 @@
local occupants = {};
local room_name, room_host = jid_split(room_jid);
+ room._affiliation_data = frozen._affiliation_data;
+
if frozen.jid and frozen._affiliations then
room._affiliations = frozen._affiliations;
else