25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +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,12 +939,28 @@ 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) ->
#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};
{NewStateData1, IsAllowed} =
case Subject of
[] ->
{StateData, true};
_ ->
case
can_change_subject(Role,
@ -953,12 +969,8 @@ process_groupchat_message(#message{from = From, lang = Lang} = Packet, StateData
of
true ->
NSD =
StateData#state{subject
=
Subject,
subject_author
=
FromNick},
StateData#state{subject = Subject,
subject_author = FromNick},
store_room(NSD),
{NSD, true};
_ -> {StateData, false}