Take in account subscriber's affiliation when checking access to moderated room

This should fix issue #3525
This commit is contained in:
Paweł Chmielowski 2021-02-17 10:45:30 +01:00
parent 14d87cb5e9
commit 14871c54ac
1 changed files with 38 additions and 26 deletions

View File

@ -939,32 +939,44 @@ process_groupchat_message(#message{from = From, lang = Lang} = Packet, StateData
of of
true -> true ->
{FromNick, Role} = get_participant_data(From, StateData), {FromNick, Role} = get_participant_data(From, StateData),
if (Role == moderator) or (Role == participant) or #config{members_by_default = MBD,
(IsSubscriber andalso ((StateData#state.config)#config.members_by_default == true)) or moderated = Moderated} = StateData#state.config,
((StateData#state.config)#config.moderated == false) -> AllowedByModerationRules =
Subject = check_subject(Packet), case {Role == moderator orelse Role == participant orelse
{NewStateData1, IsAllowed} = case Subject of not Moderated orelse MBD, IsSubscriber} of
[] -> {StateData, true}; {true, _} -> true;
_ -> {_, true} ->
case case get_default_role(get_affiliation(From, StateData),
can_change_subject(Role, StateData) of
IsSubscriber, moderator -> true;
StateData) participant -> true;
of _ -> false
true -> end;
NSD = _ ->
StateData#state{subject false
= end,
Subject, if AllowedByModerationRules ->
subject_author Subject = check_subject(Packet),
= {NewStateData1, IsAllowed} =
FromNick}, case Subject of
store_room(NSD), [] ->
{NSD, true}; {StateData, true};
_ -> {StateData, false} _ ->
end case
end, can_change_subject(Role,
case IsAllowed of IsSubscriber,
StateData)
of
true ->
NSD =
StateData#state{subject = Subject,
subject_author = FromNick},
store_room(NSD),
{NSD, true};
_ -> {StateData, false}
end
end,
case IsAllowed of
true -> true ->
case case
ejabberd_hooks:run_fold(muc_filter_message, ejabberd_hooks:run_fold(muc_filter_message,