Skip to content

Commit

Permalink
Take in account subscriber's affiliation when checking access to mode…
Browse files Browse the repository at this point in the history
…rated room

This should fix issue #3525
  • Loading branch information
prefiks committed Feb 17, 2021
1 parent 14d87cb commit 14871c5
Showing 1 changed file with 38 additions and 26 deletions.
64 changes: 38 additions & 26 deletions src/mod_muc_room.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 14871c5

Please sign in to comment.