mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Show nick also in oneself list of subscriptions (#3206)
This commit is contained in:
parent
8d969a4a9f
commit
66c2f45bff
@ -1134,7 +1134,7 @@ select_with_mucsub_fallback(LServer, JidRequestor, JidArchive, Query, RSM, Flags
|
||||
_ ->
|
||||
[]
|
||||
end,
|
||||
SubRoomJids = [Jid || {Jid, _} <- SubRooms],
|
||||
SubRoomJids = [Jid || {Jid, _, _} <- SubRooms],
|
||||
{E2, A2, C2} =
|
||||
lists:foldl(
|
||||
fun(MucJid, {E0, A0, C0}) ->
|
||||
|
@ -221,7 +221,7 @@ select_with_mucsub(LServer, JidRequestor, #jid{luser = LUser} = JidArchive,
|
||||
_ ->
|
||||
[]
|
||||
end,
|
||||
[jid:encode(Jid) || {Jid, _} <- SubRooms]
|
||||
[jid:encode(Jid) || {Jid, _, _} <- SubRooms]
|
||||
end,
|
||||
{Query, CountQuery} = make_sql_query(LUser, LServer, MAMQuery, RSM, Extra),
|
||||
do_select_query(LServer, JidRequestor, JidArchive, RSM, chat, Query, CountQuery, Flags).
|
||||
|
@ -107,7 +107,7 @@
|
||||
-callback count_online_rooms_by_user(binary(), binary(), binary()) -> non_neg_integer().
|
||||
-callback get_online_rooms_by_user(binary(), binary(), binary()) -> [{binary(), binary()}].
|
||||
-callback get_subscribed_rooms(binary(), binary(), jid()) ->
|
||||
{ok, [{jid(), [binary()]}]} | {error, db_failure}.
|
||||
{ok, [{jid(), binary(), [binary()]}]} | {error, db_failure}.
|
||||
|
||||
-optional_callbacks([get_subscribed_rooms/3]).
|
||||
|
||||
@ -701,8 +701,8 @@ process_mucsub(#iq{type = get, from = From, to = To, lang = Lang,
|
||||
ServerHost = ejabberd_router:host_of_route(Host),
|
||||
case get_subscribed_rooms(ServerHost, Host, From) of
|
||||
{ok, Subs} ->
|
||||
List = [#muc_subscription{jid = JID, events = Nodes}
|
||||
|| {JID, Nodes} <- Subs],
|
||||
List = [#muc_subscription{jid = JID, nick = Nick, events = Nodes}
|
||||
|| {JID, Nick, Nodes} <- Subs],
|
||||
xmpp:make_iq_result(IQ, #muc_subscriptions{list = List});
|
||||
{error, _} ->
|
||||
Txt = ?T("Database failure"),
|
||||
@ -946,13 +946,13 @@ get_room_disco_item({Name, Host, Pid}, {Filter, JID, Lang}) ->
|
||||
Err
|
||||
end.
|
||||
|
||||
-spec get_subscribed_rooms(binary(), jid()) -> {ok, [{jid(), [binary()]}]} | {error, any()}.
|
||||
-spec get_subscribed_rooms(binary(), jid()) -> {ok, [{jid(), binary(), [binary()]}]} | {error, any()}.
|
||||
get_subscribed_rooms(Host, User) ->
|
||||
ServerHost = ejabberd_router:host_of_route(Host),
|
||||
get_subscribed_rooms(ServerHost, Host, User).
|
||||
|
||||
-spec get_subscribed_rooms(binary(), binary(), jid()) ->
|
||||
{ok, [{jid(), [binary()]}]} | {error, any()}.
|
||||
{ok, [{jid(), binary(), [binary()]}]} | {error, any()}.
|
||||
get_subscribed_rooms(ServerHost, Host, From) ->
|
||||
LServer = jid:nameprep(ServerHost),
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
@ -964,15 +964,15 @@ get_subscribed_rooms(ServerHost, Host, From) ->
|
||||
fun({Name, _, Pid}) when Pid == self() ->
|
||||
USR = jid:split(BareFrom),
|
||||
case erlang:get(muc_subscribers) of
|
||||
#{USR := #subscriber{nodes = Nodes}} ->
|
||||
[{jid:make(Name, Host), Nodes}];
|
||||
#{USR := #subscriber{nodes = Nodes, nick = Nick}} ->
|
||||
[{jid:make(Name, Host), Nick, Nodes}];
|
||||
_ ->
|
||||
[]
|
||||
end;
|
||||
({Name, _, Pid}) ->
|
||||
case mod_muc_room:is_subscribed(Pid, BareFrom) of
|
||||
{true, Nodes} ->
|
||||
[{jid:make(Name, Host), Nodes}];
|
||||
{true, Nick, Nodes} ->
|
||||
[{jid:make(Name, Host), Nick, Nodes}];
|
||||
false -> []
|
||||
end;
|
||||
(_) ->
|
||||
|
@ -223,7 +223,7 @@ unsubscribe(Pid, JID) ->
|
||||
{error, ?T("Conference room does not exist")}
|
||||
end.
|
||||
|
||||
-spec is_subscribed(pid(), jid()) -> {true, [binary()]} | false.
|
||||
-spec is_subscribed(pid(), jid()) -> {true, binary(), [binary()]} | false.
|
||||
is_subscribed(Pid, JID) ->
|
||||
try p1_fsm:sync_send_all_state_event(Pid, {is_subscribed, JID})
|
||||
catch _:{_, {p1_fsm, _, _}} -> false
|
||||
@ -759,7 +759,7 @@ handle_sync_event({muc_unsubscribe, From}, _From, StateName,
|
||||
end;
|
||||
handle_sync_event({is_subscribed, From}, _From, StateName, StateData) ->
|
||||
IsSubs = try maps:get(jid:split(From), StateData#state.subscribers) of
|
||||
#subscriber{nodes = Nodes} -> {true, Nodes}
|
||||
#subscriber{nick = Nick, nodes = Nodes} -> {true, Nick, Nodes}
|
||||
catch _:{badkey, _} -> false
|
||||
end,
|
||||
{reply, IsSubs, StateName, StateData};
|
||||
|
@ -410,11 +410,11 @@ get_subscribed_rooms(LServer, Host, Jid) ->
|
||||
JidS = jid:encode(Jid),
|
||||
case ejabberd_sql:sql_query(
|
||||
LServer,
|
||||
?SQL("select @(room)s, @(nodes)s from muc_room_subscribers "
|
||||
?SQL("select @(room)s, @(nick)s, @(nodes)s from muc_room_subscribers "
|
||||
"where jid=%(JidS)s and host=%(Host)s")) of
|
||||
{selected, Subs} ->
|
||||
{ok, [{jid:make(Room, Host), ejabberd_sql:decode_term(Nodes)}
|
||||
|| {Room, Nodes} <- Subs]};
|
||||
{ok, [{jid:make(Room, Host), Nick, ejabberd_sql:decode_term(Nodes)}
|
||||
|| {Room, Nick, Nodes} <- Subs]};
|
||||
_Error ->
|
||||
{error, db_failure}
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user