Skip to content

Commit

Permalink
Start use ejabberd_config:get_global_option_or_default/2 for lists op…
Browse files Browse the repository at this point in the history
…erations in MIM
  • Loading branch information
vkatsuba committed Aug 16, 2021
1 parent 18b2168 commit 2714043
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/admin_extra/service_admin_extra_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ stats(Name) ->
<<"registeredusers">> ->
lists:sum([
ejabberd_auth:get_vh_registered_users_number(Server)
|| Server <- ejabberd_config:get_global_option(hosts) ]);
|| Server <- ejabberd_config:get_global_option_or_default(hosts, []) ]);
<<"onlineusersnode">> ->
ejabberd_sm:get_node_sessions_number();
<<"onlineusers">> ->
Expand Down
2 changes: 1 addition & 1 deletion src/ejabberd_service.erl
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ unregister_routes(StateData) ->
ejabberd_router:unregister_components(Routes).

get_routes(#state{host=Subdomain, is_subdomain=true}) ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
component_routes(Subdomain, Hosts);
get_routes(#state{host=Host}) ->
[Host].
Expand Down
2 changes: 1 addition & 1 deletion src/mod_bosh.erl
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ maybe_start_session_on_known_host_unsafe(Host, Req, Body) ->

%% @doc Is the argument locally served host?
is_known_host(Host) ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
lists:member(Host, Hosts).

-spec start_session(jid:lserver(), mongoose_transport:peer(),
Expand Down
2 changes: 1 addition & 1 deletion src/mod_smart_markers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ get_host(groupchat, SubHost, From, To) ->
can_access_room(HostType, From, To) andalso {true, HostType}
end;
get_host(one2one, Host, _, _) ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
case lists:member(Host, Hosts) of
false -> false;
_ -> {true, Host}
Expand Down
4 changes: 2 additions & 2 deletions src/system_metrics/mongoose_system_metrics_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ get_hosts_count() ->
[#{report_name => hosts, key => count, value => NumberOfHosts}].

get_modules() ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
AllModules = lists:flatten([gen_mod:loaded_modules(H) || H <- Hosts]),
ModulesToReport = filter_behaviour_implementations(lists:usort(AllModules),
mongoose_module_metrics),
Expand Down Expand Up @@ -78,7 +78,7 @@ report_module_with_opts(Module, Opts) ->
end,Opts).

get_number_of_custom_modules() ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
AllModules = lists:flatten(
lists:map(fun gen_mod:loaded_modules/1, Hosts)),
GenMods = filter_behaviour_implementations(AllModules, gen_mod),
Expand Down

0 comments on commit 2714043

Please sign in to comment.