aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2021-11-16 12:57:04 +0000
committerMatthew Wild <mwild1@gmail.com>2021-11-16 12:57:04 +0000
commit3a21513b61019736e65144bbe6e6323e53c7fde2 (patch)
tree599d8f67c30bafdb059736370db2dab57ca943be /plugins/muc
parentf5fd67c3e78b9251f8374910bfe58a00495cc02d (diff)
downloadprosody-3a21513b61019736e65144bbe6e6323e53c7fde2.tar.gz
prosody-3a21513b61019736e65144bbe6e6323e53c7fde2.zip
MUC: Add room:set_affiliation_data()
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index a62ad5c5..ef418b2b 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1532,6 +1532,28 @@ function room_mt:get_affiliation_data(jid, key)
return data;
end
+function room_mt:set_affiliation_data(jid, key, value)
+ if key == nil then return nil, "invalid key"; end
+ local data = self._affiliation_data[jid];
+ if not data then
+ if value == nil then return true; end
+ data = {};
+ end
+ local old_value = data[key];
+ data[key] = value;
+ if old_value ~= value then
+ module:fire_event("muc-set-affiliation-data/"..key, {
+ room = self;
+ jid = jid;
+ key = key;
+ value = value;
+ old_value = old_value;
+ });
+ end
+ self:save(true);
+ return true;
+end
+
function room_mt:get_role(nick)
local occupant = self:get_occupant_by_nick(nick);
return occupant and occupant.role or nil;