From 30ff6c8862a7d0db017119afd61e413c8ab8d823 Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 5 Jun 2024 13:11:57 +0200 Subject: [PATCH] Fix feature: Add support to generate link to room page --- src/ejabberd_web_admin.erl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index b4791b7bf37..0fee546587c 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -1661,7 +1661,7 @@ when | {result_links, [ { ResultName :: atom(), - LinkType :: host | node | user | arg_host | paragraph, + LinkType :: host | node | user | room | arg_host | paragraph, Level :: integer(), Append :: binary() } @@ -1701,7 +1701,7 @@ when | {result_links, [ { ResultName :: atom(), - LinkType :: host | node | user | arg_host | paragraph, + LinkType :: host | node | user | room | arg_host | paragraph, Level :: integer(), Append :: binary() } @@ -2262,6 +2262,23 @@ make_result(Binary, ElementName, _ArgumentsUsed, [{ResultName, user, Level, Appe false -> ?C(Binary) end; +make_result(Binary, ElementName, _ArgumentsUsed, [{ResultName, room, Level, Append}]) when + (ElementName == ResultName) or (ElementName == unknown_element_name) +-> + Jid = jid:decode(Binary), + {Roomname, Service, _} = jid:split(Jid), + Host = ejabberd_router:host_of_route(Service), + case lists:member(Host, ejabberd_config:get_option(hosts)) of + true -> + UrlBinary = replace_url_elements( + [<<"server/">>, host, <<"/muc/rooms/room/">>, room, <<"/">>, Append], + [{room, misc:url_encode(Roomname)}, {host, Host}], + Level + ), + ?AC(UrlBinary, Binary); + false -> + ?C(Binary) + end; make_result(Binary, ElementName, _ArgumentsUsed, [{ResultName, shared_roster, Level, Append}]) when (ElementName == ResultName) or (ElementName == unknown_element_name) ->