Skip to content

Commit

Permalink
Merge remote-tracking branch 'processone/pr/351'
Browse files Browse the repository at this point in the history
* processone/pr/351:
  mod_pubsub_serverinfo: ensure public_hosts is a list
  • Loading branch information
weiss committed Jan 11, 2025
2 parents 217710d + 8f62036 commit 590a3cd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mod_pubsub_serverinfo/src/mod_pubsub_serverinfo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ init([Host, _Opts]) ->
self() ! update_pubsub,
{ok, State}.

-spec init_monitors(binary()) -> map().
init_monitors(Host) ->
lists:foldl(
fun(Domain, Monitors) ->
Expand All @@ -84,12 +85,18 @@ init_monitors(Host) ->
#{},
ejabberd_option:hosts() -- [Host]).

-spec fetch_public_hosts() -> list().
fetch_public_hosts() ->
try
{ok, {{_, 200, _}, _Headers, Body}} = httpc:request(?PUBLIC_HOSTS_URL),
misc:json_decode(Body)
catch _E:_R ->
?WARNING_MSG("Failed retrieving public hosts (~p): ~p", [_E, _R]),
case misc:json_decode(Body) of
PublicHosts when is_list(PublicHosts) -> PublicHosts;
Other ->
?WARNING_MSG("Parsed JSON for public hosts was not a list: ~p", [Other]),
[]
end
catch E:R ->
?WARNING_MSG("Failed fetching public hosts (~p): ~p", [E, R]),
[]
end.

Expand Down

0 comments on commit 590a3cd

Please sign in to comment.