mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
First check occupant existence, later check the message
This commit is contained in:
parent
75fc431fb8
commit
41d028d101
@ -426,14 +426,7 @@ normal_state({route, From, ToNick,
|
||||
ToNick),
|
||||
From, Err);
|
||||
_ ->
|
||||
ToJIDs = find_jids_by_nick(ToNick, StateData),
|
||||
SrcIsVisitor = is_visitor(From, StateData),
|
||||
DstIsModerator = is_moderator(hd(ToJIDs), StateData),
|
||||
PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors,
|
||||
if SrcIsVisitor == false;
|
||||
PmFromVisitors == anyone;
|
||||
(PmFromVisitors == moderators) and (DstIsModerator) ->
|
||||
case ToJIDs of
|
||||
case find_jids_by_nick(ToNick, StateData) of
|
||||
false ->
|
||||
ErrText = "Recipient is not in the conference room",
|
||||
Err = jlib:make_error_reply(
|
||||
@ -443,13 +436,18 @@ normal_state({route, From, ToNick,
|
||||
StateData#state.jid,
|
||||
ToNick),
|
||||
From, Err);
|
||||
_ ->
|
||||
ToJIDs ->
|
||||
SrcIsVisitor = is_visitor(From, StateData),
|
||||
DstIsModerator = is_moderator(hd(ToJIDs), StateData),
|
||||
PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors,
|
||||
if SrcIsVisitor == false;
|
||||
PmFromVisitors == anyone;
|
||||
(PmFromVisitors == moderators) and (DstIsModerator) ->
|
||||
{ok, #user{nick = FromNick}} =
|
||||
?DICT:find(jlib:jid_tolower(From),
|
||||
StateData#state.users),
|
||||
FromNickJID = jlib:jid_replace_resource(StateData#state.jid, FromNick),
|
||||
[ejabberd_router:route(FromNickJID, ToJID, Packet) || ToJID <- ToJIDs]
|
||||
end;
|
||||
[ejabberd_router:route(FromNickJID, ToJID, Packet) || ToJID <- ToJIDs];
|
||||
true ->
|
||||
ErrText = "It is not allowed to send private messages",
|
||||
Err = jlib:make_error_reply(
|
||||
@ -460,6 +458,7 @@ normal_state({route, From, ToNick,
|
||||
ToNick),
|
||||
From, Err)
|
||||
end
|
||||
end
|
||||
end;
|
||||
{true, false} ->
|
||||
ErrText = "Only occupants are allowed to send messages to the conference",
|
||||
|
Loading…
Reference in New Issue
Block a user