Comparison

plugins/muc/muc.lib.lua @ 8915:2502be210a85

MUC: Normalize role value, fixes removal on loss of membership (thanks mimi89999)
author Kim Alvefur <zash@zash.se>
date Mon, 18 Jun 2018 04:25:01 +0200
parent 8914:e9acb928c637
child 8931:ae84911c1441
comparison
equal deleted inserted replaced
8914:e9acb928c637 8915:2502be210a85
49 local role = module:fire_event("muc-get-default-role", { 49 local role = module:fire_event("muc-get-default-role", {
50 room = self; 50 room = self;
51 affiliation = affiliation; 51 affiliation = affiliation;
52 affiliation_rank = valid_affiliations[affiliation or "none"]; 52 affiliation_rank = valid_affiliations[affiliation or "none"];
53 }); 53 });
54 role = role ~= "none" and role or nil; -- coerces `role == false` to `nil`
54 return role, valid_roles[role or "none"]; 55 return role, valid_roles[role or "none"];
55 end 56 end
56 module:hook("muc-get-default-role", function(event) 57 module:hook("muc-get-default-role", function(event)
57 if event.affiliation_rank >= valid_affiliations.admin then 58 if event.affiliation_rank >= valid_affiliations.admin then
58 return "moderator"; 59 return "moderator";