Persist `none` role for outcasts

`none` roles *should* be persisted for banned users. I totally forgot about this, my bad. I'm shocked nobody else noticed it.
This commit is contained in:
Blake Miller 2023-03-19 01:40:19 -04:00 committed by GitHub
parent 04b431f191
commit 75d75c5351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -1751,10 +1751,12 @@ set_role(JID, Role, StateData) ->
end, StateData#state.users, LJIDs),
StateData#state.nicks}
end,
Affiliation = get_affiliation(JID, StateData),
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 ->
%% maintain the same role they had *before* they were kicked,
%% unless they were banned
none when Affiliation /= outcast ->
StateData#state.roles;
NewRole ->
maps:put(jid:remove_resource(LJID),
@ -3070,7 +3072,7 @@ process_item_change(Item, SD, UJID) ->
process_iq_mucsub(JID,
#iq{type = set,
sub_els = [#muc_unsubscribe{}]}, SD),
set_affiliation(JID, outcast, set_role(JID, none, SD2), Reason);
set_role(JID, none, set_affiliation(JID, outcast, SD2, Reason));
{JID, affiliation, A, Reason} when (A == admin) or (A == owner) ->
SD1 = set_affiliation(JID, A, SD, Reason),
SD2 = set_role(JID, moderator, SD1),