From 83e6741117d532470951b2c96f247a4047860348 Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Mon, 8 Jul 2019 09:55:32 +0300 Subject: [PATCH] Use maps instead of dict --- src/ejabberd_service.erl | 14 +++++++------- src/mod_http_fileserver.erl | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 45903a01a..503562456 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -107,7 +107,7 @@ init([State, Opts]) -> xmlns => ?NS_COMPONENT, lang => ejabberd_option:language(), server => ejabberd_config:get_myname(), - host_opts => dict:from_list(HostOpts1), + host_opts => maps:from_list(HostOpts1), stream_version => undefined, tls_options => TLSOpts, global_routes => GlobalRoutes, @@ -123,13 +123,13 @@ handle_stream_start(_StreamStart, Txt = ?T("Unable to register route on existing local domain"), xmpp_stream_in:send(State, xmpp:serr_conflict(Txt, Lang)); false -> - NewHostOpts = case dict:is_key(RemoteServer, HostOpts) of + NewHostOpts = case maps:is_key(RemoteServer, HostOpts) of true -> HostOpts; false -> - case dict:find(global, HostOpts) of + case maps:find(global, HostOpts) of {ok, GlobalPass} -> - dict:from_list([{RemoteServer, GlobalPass}]); + maps:from_list([{RemoteServer, GlobalPass}]); error -> HostOpts end @@ -142,7 +142,7 @@ get_password_fun(#{remote_server := RemoteServer, socket := Socket, ip := IP, host_opts := HostOpts}) -> fun(_) -> - case dict:find(RemoteServer, HostOpts) of + case maps:find(RemoteServer, HostOpts) of {ok, Password} -> {Password, undefined}; error -> @@ -163,7 +163,7 @@ handle_auth_success(_, Mech, _, [xmpp_socket:pp(Socket), Mech, RemoteServer, ejabberd_config:may_hide_data(misc:ip_to_list(IP))]), Routes = if GlobalRoutes -> - dict:fetch_keys(HostOpts); + maps:keys(HostOpts); true -> [RemoteServer] end, @@ -245,7 +245,7 @@ check_from(_From, #{check_from := false}) -> check_from(From, #{host_opts := HostOpts}) -> %% The default is the standard behaviour in XEP-0114 Server = From#jid.lserver, - dict:is_key(Server, HostOpts). + maps:is_key(Server, HostOpts). random_password() -> str:sha(p1_rand:bytes(20)). diff --git a/src/mod_http_fileserver.erl b/src/mod_http_fileserver.erl index 01af8a2a5..71cc6b178 100644 --- a/src/mod_http_fileserver.erl +++ b/src/mod_http_fileserver.erl @@ -131,7 +131,7 @@ initialize(Host, Opts) -> UserAccess = case UserAccess0 of [] -> none; _ -> - dict:from_list(UserAccess0) + maps:from_list(UserAccess0) end, ContentTypes = build_list_content_types( mod_http_fileserver_opt:content_types(Opts), @@ -285,7 +285,7 @@ serve(LocalPath, Auth, DocRoot, DirectoryIndices, CustomHeaders, DefaultContentT CanProceed = case {UserAccess, Auth} of {none, _} -> true; {_, {User, Pass}} -> - case dict:find(User, UserAccess) of + case maps:find(User, UserAccess) of {ok, Pass} -> true; _ -> false end; -- 2.40.0