25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

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

View File

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