Don't persist 'none' role (thanks to Blake Miller)(#3330)

This commit is contained in:
Badlop 2022-09-07 16:44:50 +02:00
parent 4d3875f4ff
commit a8121cd7e5
1 changed files with 10 additions and 1 deletions

View File

@ -1732,7 +1732,16 @@ set_role(JID, Role, StateData) ->
end, StateData#state.users, LJIDs),
StateData#state.nicks}
end,
Roles = maps:put(jid:remove_resource(LJID), Role, StateData#state.roles),
Roles = case Role of
%% Don't persist 'none' role: if someone is kicked, they will
%% maintain the same role they had *before* they were kicked
none ->
StateData#state.roles;
NewRole ->
maps:put(jid:remove_resource(LJID),
NewRole,
StateData#state.roles)
end,
StateData#state{users = Users, nicks = Nicks, roles = Roles}.
-spec get_role(jid(), state()) -> role().