aboutsummaryrefslogtreecommitdiff
path: root/src/mod_admin_extra.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2017-02-23 23:27:57 +0100
committerBadlop <badlop@process-one.net>2017-02-23 23:27:57 +0100
commit57181c0a76f52334fe903c6680e4debb5b6f1c13 (patch)
treeef5bae5a1e8787bbc24813bf7714545c3cecdff8 /src/mod_admin_extra.erl
parentProtect users from delete_old_users command using a fixed access rule (#1462) (diff)
get_last now always returns tuple with UTC XEP-0082 and status (#1565)
Diffstat (limited to 'src/mod_admin_extra.erl')
-rw-r--r--src/mod_admin_extra.erl32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl
index d52f6f4ba..50f651ec3 100644
--- a/src/mod_admin_extra.erl
+++ b/src/mod_admin_extra.erl
@@ -538,12 +538,15 @@ get_commands_spec() ->
result = {res, rescode}},
#ejabberd_commands{name = get_last, tags = [last],
- desc = "Get last activity information (timestamp and status)",
- longdesc = "Timestamp is the seconds since"
- "1970-01-01 00:00:00 UTC, for example: date +%s",
+ desc = "Get last activity information",
+ longdesc = "Timestamp is UTC and XEP-0082 format, for example: "
+ "2017-02-23T22:25:28.063062Z ONLINE",
module = ?MODULE, function = get_last,
args = [{user, binary}, {host, binary}],
- result = {last_activity, string}},
+ result = {last_activity,
+ {tuple, [{timestamp, string},
+ {status, string}
+ ]}}},
#ejabberd_commands{name = set_last, tags = [last],
desc = "Set last activity information",
longdesc = "Timestamp is the seconds since"
@@ -1337,25 +1340,18 @@ build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
%%%
get_last(User, Server) ->
- case ejabberd_sm:get_user_resources(User, Server) of
+ {Now, Status} = case ejabberd_sm:get_user_resources(User, Server) of
[] ->
case mod_last:get_last_info(User, Server) of
not_found ->
- "Never";
- {ok, Shift, Status} ->
- TimeStamp = {Shift div 1000000,
- Shift rem 1000000,
- 0},
- {{Year, Month, Day}, {Hour, Minute, Second}} =
- calendar:now_to_local_time(TimeStamp),
- lists:flatten(
- io_lib:format(
- "~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w ~s",
- [Year, Month, Day, Hour, Minute, Second, Status]))
+ {now(), "NOT FOUND"};
+ {ok, Shift, Status1} ->
+ {{Shift div 1000000, Shift rem 1000000, 0}, Status1}
end;
_ ->
- "Online"
- end.
+ {now(), "ONLINE"}
+ end,
+ {xmpp_util:encode_timestamp(Now), Status}.
%%%
%%% Private Storage