]> granicus.if.org Git - ejabberd/commitdiff
Check if mod_last is loaded before calling its functions
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Mon, 24 Jun 2019 15:47:51 +0000 (18:47 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Mon, 24 Jun 2019 15:47:51 +0000 (18:47 +0300)
src/ejabberd_web_admin.erl

index 256920c25d9a04d0bc98fd3a31f759b5e5958af2..c50d51bb90c9919dbc435bb59a14b72023c93eba 100644 (file)
@@ -707,9 +707,7 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
                                                                         Server)
                                            of
                                          [] ->
-                                             case mod_last:get_last_info(User,
-                                                                         Server)
-                                                 of
+                                             case get_last_info(User, Server) of
                                                not_found -> translate:translate(Lang, ?T("Never"));
                                                {ok, Shift, _Status} ->
                                                    TimeStamp = {Shift div
@@ -755,9 +753,22 @@ get_offlinemsg_module(Server) ->
     end.
 
 get_lastactivity_menuitem_list(Server) ->
-    case mod_last_opt:db_type(Server) of
-      mnesia -> [{<<"last-activity">>, ?T("Last Activity")}];
-      _ -> []
+    case gen_mod:is_loaded(Server, mod_last) of
+       true ->
+           case mod_last_opt:db_type(Server) of
+               mnesia -> [{<<"last-activity">>, ?T("Last Activity")}];
+               _ -> []
+           end;
+       false ->
+           []
+    end.
+
+get_last_info(User, Server) ->
+    case gen_mod:is_loaded(Server, mod_last) of
+       true ->
+           mod_last:get_last_info(User, Server);
+       false ->
+           not_found
     end.
 
 us_to_list({User, Server}) ->
@@ -890,7 +901,7 @@ user_info(User, Server, Query, Lang) ->
                                                       Server)
                       of
                     [] ->
-                        case mod_last:get_last_info(User, Server) of
+                        case get_last_info(User, Server) of
                           not_found -> translate:translate(Lang, ?T("Never"));
                           {ok, Shift, _Status} ->
                               TimeStamp = {Shift div 1000000,