mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-02 21:17:12 +02:00
Send private messages to all the sessions with same nick (EJAB-305)
This commit is contained in:
parent
c76bbdf16f
commit
9a190f3bc4
|
@ -426,14 +426,14 @@ normal_state({route, From, ToNick,
|
||||||
ToNick),
|
ToNick),
|
||||||
From, Err);
|
From, Err);
|
||||||
_ ->
|
_ ->
|
||||||
ToJID = find_jid_by_nick(ToNick, StateData),
|
ToJIDs = find_jids_by_nick(ToNick, StateData),
|
||||||
SrcIsVisitor = is_visitor(From, StateData),
|
SrcIsVisitor = is_visitor(From, StateData),
|
||||||
DstIsModerator = is_moderator(ToJID, StateData),
|
DstIsModerator = is_moderator(hd(ToJIDs), StateData),
|
||||||
PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors,
|
PmFromVisitors = (StateData#state.config)#config.allow_private_messages_from_visitors,
|
||||||
if SrcIsVisitor == false;
|
if SrcIsVisitor == false;
|
||||||
PmFromVisitors == anyone;
|
PmFromVisitors == anyone;
|
||||||
(PmFromVisitors == moderators) and (DstIsModerator) ->
|
(PmFromVisitors == moderators) and (DstIsModerator) ->
|
||||||
case ToJID of
|
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(
|
||||||
|
@ -447,11 +447,8 @@ normal_state({route, From, ToNick,
|
||||||
{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),
|
||||||
ejabberd_router:route(
|
FromNickJID = jlib:jid_replace_resource(StateData#state.jid, FromNick),
|
||||||
jlib:jid_replace_resource(
|
[ejabberd_router:route(FromNickJID, ToJID, Packet) || ToJID <- ToJIDs]
|
||||||
StateData#state.jid,
|
|
||||||
FromNick),
|
|
||||||
ToJID, Packet)
|
|
||||||
end;
|
end;
|
||||||
true ->
|
true ->
|
||||||
ErrText = "It is not allowed to send private messages",
|
ErrText = "It is not allowed to send private messages",
|
||||||
|
@ -1548,6 +1545,18 @@ add_user_presence_un(JID, Presence, StateData) ->
|
||||||
StateData#state{users = Users}.
|
StateData#state{users = Users}.
|
||||||
|
|
||||||
|
|
||||||
|
%% Find and return a list of the full JIDs of the users of Nick.
|
||||||
|
%% Return jid record.
|
||||||
|
find_jids_by_nick(Nick, StateData) ->
|
||||||
|
case ?DICT:find(Nick, StateData#state.nicks) of
|
||||||
|
{ok, [User]} ->
|
||||||
|
[jlib:make_jid(User)];
|
||||||
|
{ok, Users} ->
|
||||||
|
[jlib:make_jid(LJID) || LJID <- Users];
|
||||||
|
error ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
||||||
%% Find and return the full JID of the user of Nick with
|
%% Find and return the full JID of the user of Nick with
|
||||||
%% highest-priority presence. Return jid record.
|
%% highest-priority presence. Return jid record.
|
||||||
find_jid_by_nick(Nick, StateData) ->
|
find_jid_by_nick(Nick, StateData) ->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user