aboutsummaryrefslogtreecommitdiff
path: root/src/mod_offline.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_offline.erl')
-rw-r--r--src/mod_offline.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mod_offline.erl b/src/mod_offline.erl
index 9462d77f0..63537600e 100644
--- a/src/mod_offline.erl
+++ b/src/mod_offline.erl
@@ -16,6 +16,7 @@
stop/0,
store_packet/3,
resend_offline_messages/1,
+ remove_old_messages/1,
remove_user/1]).
-include("jlib.hrl").
@@ -150,6 +151,22 @@ resend_offline_messages(User) ->
ok
end.
+remove_old_messages(Days) ->
+ {MegaSecs, Secs, _MicroSecs} = now(),
+ S = MegaSecs * 1000000 + Secs - 60 * 60 * 24 * Days,
+ MegaSecs1 = S div 1000000,
+ Secs1 = S rem 1000000,
+ TimeStamp = {MegaSecs1, Secs1, 0},
+ F = fun() ->
+ mnesia:foldl(
+ fun(#offline_msg{timestamp = TS} = Rec, _Acc)
+ when TS < TimeStamp ->
+ mnesia:delete_object(Rec);
+ (_Rec, _Acc) -> ok
+ end, ok, offline_msg)
+ end,
+ mnesia:transaction(F).
+
remove_user(User) ->
LUser = jlib:nodeprep(User),
F = fun() ->