25
1
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:
Badlop 2011-09-04 13:28:32 +02:00
parent 75fc431fb8
commit 41d028d101

View File

@ -426,14 +426,7 @@ normal_state({route, From, ToNick,
ToNick), ToNick),
From, Err); From, Err);
_ -> _ ->
ToJIDs = find_jids_by_nick(ToNick, StateData), case find_jids_by_nick(ToNick, StateData) of
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
false -> false ->
ErrText = "Recipient is not in the conference room", ErrText = "Recipient is not in the conference room",
Err = jlib:make_error_reply( Err = jlib:make_error_reply(
@ -443,13 +436,18 @@ normal_state({route, From, ToNick,
StateData#state.jid, StateData#state.jid,
ToNick), ToNick),
From, Err); 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}} = {ok, #user{nick = FromNick}} =
?DICT:find(jlib:jid_tolower(From), ?DICT:find(jlib:jid_tolower(From),
StateData#state.users), StateData#state.users),
FromNickJID = jlib:jid_replace_resource(StateData#state.jid, FromNick), FromNickJID = jlib:jid_replace_resource(StateData#state.jid, FromNick),
[ejabberd_router:route(FromNickJID, ToJID, Packet) || ToJID <- ToJIDs] [ejabberd_router:route(FromNickJID, ToJID, Packet) || ToJID <- ToJIDs];
end;
true -> true ->
ErrText = "It is not allowed to send private messages", ErrText = "It is not allowed to send private messages",
Err = jlib:make_error_reply( Err = jlib:make_error_reply(
@ -460,6 +458,7 @@ normal_state({route, From, ToNick,
ToNick), ToNick),
From, Err) From, Err)
end end
end
end; end;
{true, false} -> {true, false} ->
ErrText = "Only occupants are allowed to send messages to the conference", ErrText = "Only occupants are allowed to send messages to the conference",