Comparison

plugins/muc/muc.lib.lua @ 11911:0e7dedd8b18d

MUC: Add room:set_affiliation_data()
author Matthew Wild <mwild1@gmail.com>
date Tue, 16 Nov 2021 12:57:04 +0000
parent 11910:3a8ec48f7333
child 11912:037b2c019f58
comparison
equal deleted inserted replaced
11910:3a8ec48f7333 11911:0e7dedd8b18d
1530 return data[key]; 1530 return data[key];
1531 end 1531 end
1532 return data; 1532 return data;
1533 end 1533 end
1534 1534
1535 function room_mt:set_affiliation_data(jid, key, value)
1536 if key == nil then return nil, "invalid key"; end
1537 local data = self._affiliation_data[jid];
1538 if not data then
1539 if value == nil then return true; end
1540 data = {};
1541 end
1542 local old_value = data[key];
1543 data[key] = value;
1544 if old_value ~= value then
1545 module:fire_event("muc-set-affiliation-data/"..key, {
1546 room = self;
1547 jid = jid;
1548 key = key;
1549 value = value;
1550 old_value = old_value;
1551 });
1552 end
1553 self:save(true);
1554 return true;
1555 end
1556
1535 function room_mt:get_role(nick) 1557 function room_mt:get_role(nick)
1536 local occupant = self:get_occupant_by_nick(nick); 1558 local occupant = self:get_occupant_by_nick(nick);
1537 return occupant and occupant.role or nil; 1559 return occupant and occupant.role or nil;
1538 end 1560 end
1539 1561