]> granicus.if.org Git - ejabberd/commitdiff
Simplify internal code of get_last and set_last commands
authorBadlop <badlop@process-one.net>
Tue, 5 May 2015 10:54:20 +0000 (12:54 +0200)
committerBadlop <badlop@process-one.net>
Tue, 5 May 2015 10:54:20 +0000 (12:54 +0200)
src/mod_admin_extra.erl

index 75233a732c906a02edbbdaba79dd60c704509908..023c29dcd941d22e415b0850310f64bd3a0301ad 100644 (file)
@@ -70,7 +70,6 @@
         push_alltoall/2,
         %% mod_last
         get_last/2,
-        set_last/4,
         %% mod_private
         private_get/4,
         private_set/3,
@@ -445,7 +444,7 @@ commands() ->
                        desc = "Set last activity information",
                        longdesc = "Timestamp is the seconds since"
                        "1970-01-01 00:00:00 UTC, for example: date +%s",
-                       module = ?MODULE, function = set_last,
+                       module = mod_last, function = store_last_info,
                        args = [{user, binary}, {host, binary}, {timestamp, integer}, {status, binary}],
                        result = {res, rescode}},
 
@@ -680,7 +679,7 @@ delete_old_users(Days, Users) ->
                    %% If it isnt
                    [] ->
                        %% Look for his last_activity
-                       case (get_lastactivity_module(LServer)):get_last_info(LUser, LServer) of
+                       case mod_last:get_last_info(LUser, LServer) of
                            %% If it is
                            %% existent:
                            {ok, TimeStamp, _Status} ->
@@ -714,13 +713,6 @@ delete_old_users(Days, Users) ->
     Users_removed = lists:filter(F, Users),
     {removed, length(Users_removed), Users_removed}.
 
-get_lastactivity_module(Server) ->
-    case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
-        true -> mod_last;
-        _ -> mod_last_odbc
-    end.
-
-
 %%
 %% Ban account
 
@@ -1220,10 +1212,9 @@ build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
 %%%
 
 get_last(User, Server) ->
-    Mod = get_lastactivity_module(Server),
     case ejabberd_sm:get_user_resources(User, Server) of
         [] ->
-            case Mod:get_last_info(User, Server) of
+            case mod_last:get_last_info(User, Server) of
                 not_found ->
                     "Never";
                 {ok, Shift, Status} ->
@@ -1241,10 +1232,6 @@ get_last(User, Server) ->
             "Online"
     end.
 
-set_last(User, Server, Timestamp, Status) ->
-    Mod = get_lastactivity_module(Server),
-    Mod:store_last_info(User, Server, Timestamp, Status).
-
 %%%
 %%% Private Storage
 %%%