]> granicus.if.org Git - ejabberd/commitdiff
Use maps instead of dict
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Mon, 8 Jul 2019 06:55:32 +0000 (09:55 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Mon, 8 Jul 2019 06:55:32 +0000 (09:55 +0300)
src/ejabberd_service.erl
src/mod_http_fileserver.erl

index 45903a01a0d34e0998e46ddb42eef2703a75ae9f..503562456d2d022f433324106cbb56417ddd907f 100644 (file)
@@ -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)).
index 01af8a2a533442691eb60945778ffc1c2b5f2676..71cc6b1788046744c45f8f3335f1e7ddeee118a9 100644 (file)
@@ -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;