Comparison

plugins/muc/muc.lib.lua @ 9831:43f81e85cec2

MUC: Fire an event to allow affecting decision of whether to allow a role change
author Kim Alvefur <zash@zash.se>
date Sun, 24 Feb 2019 16:30:11 +0100
parent 9830:d935a0f0de24
child 9862:f5623a1b33e5
comparison
equal deleted inserted replaced
9830:d935a0f0de24 9831:43f81e85cec2
1367 local occupant = self:get_occupant_by_nick(nick); 1367 local occupant = self:get_occupant_by_nick(nick);
1368 return occupant and occupant.role or nil; 1368 return occupant and occupant.role or nil;
1369 end 1369 end
1370 1370
1371 function room_mt:may_set_role(actor, occupant, role) 1371 function room_mt:may_set_role(actor, occupant, role)
1372 local event = {
1373 room = self,
1374 actor = actor,
1375 occupant = occupant,
1376 role = role,
1377 };
1378
1379 module:fire_event("muc-pre-set-role", event);
1380 if event.allowed ~= nil then
1381 return event.allowed, event.error, event.condition;
1382 end
1383
1372 -- Can't do anything to other owners or admins 1384 -- Can't do anything to other owners or admins
1373 local occupant_affiliation = self:get_affiliation(occupant.bare_jid); 1385 local occupant_affiliation = self:get_affiliation(occupant.bare_jid);
1374 if occupant_affiliation == "owner" or occupant_affiliation == "admin" then 1386 if occupant_affiliation == "owner" or occupant_affiliation == "admin" then
1375 return nil, "cancel", "not-allowed"; 1387 return nil, "cancel", "not-allowed";
1376 end 1388 end