Software /
code /
prosody
Changeset
11911:0e7dedd8b18d
MUC: Add room:set_affiliation_data()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 16 Nov 2021 12:57:04 +0000 |
parents | 11910:3a8ec48f7333 |
children | 11912:037b2c019f58 |
files | plugins/muc/muc.lib.lua |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua Tue Nov 16 12:02:54 2021 +0000 +++ b/plugins/muc/muc.lib.lua Tue Nov 16 12:57:04 2021 +0000 @@ -1532,6 +1532,28 @@ 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;