aboutsummaryrefslogtreecommitdiff
path: root/src/mod_last.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2013-07-21 20:24:36 +1000
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2013-07-21 23:10:38 +1000
commitd58148fa8db82628304ec32b50b3d3ef70c5879e (patch)
tree57310c31d1650344d3de01b50b24d5c8602418e7 /src/mod_last.erl
parentMake it possible to enable/disable TLS compression (diff)
Add SQL to Mnesia converter
Diffstat (limited to 'src/mod_last.erl')
-rw-r--r--src/mod_last.erl16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mod_last.erl b/src/mod_last.erl
index 28fcda63a..3ea86b350 100644
--- a/src/mod_last.erl
+++ b/src/mod_last.erl
@@ -31,7 +31,7 @@
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3, export/1,
- process_sm_iq/3, on_presence_update/4,
+ process_sm_iq/3, on_presence_update/4, import/1, import/3,
store_last_info/4, get_last_info/2, remove_user/2]).
-include("ejabberd.hrl").
@@ -305,3 +305,17 @@ export(_Server) ->
(_Host, _R) ->
[]
end}].
+
+import(LServer) ->
+ [{<<"select username, seconds, state from last">>,
+ fun([LUser, TimeStamp, State]) ->
+ #last_activity{us = {LUser, LServer},
+ timestamp = jlib:binary_to_integer(
+ TimeStamp),
+ status = State}
+ end}].
+
+import(_LServer, mnesia, #last_activity{} = LA) ->
+ mnesia:dirty_write(LA);
+import(_, _, _) ->
+ pass.