./ct_report/coverage/mod_inbox_commands.COVER.html

1 -module(mod_inbox_commands).
2
3 -behaviour(gen_mod).
4
5 %% gen_mod
6 -export([start/2, stop/1, supported_features/0]).
7
8 -export([flush_user_bin/3, flush_global_bin/2]).
9 -ignore_xref([flush_user_bin/3, flush_global_bin/2]).
10
11 %% Initialisation
12 -spec start(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
13 start(_, _) ->
14
:-(
mongoose_commands:register(commands()).
15
16 stop(_) ->
17
:-(
mongoose_commands:unregister(commands()).
18
19 -spec supported_features() -> [atom()].
20 supported_features() ->
21
:-(
[dynamic_domains].
22
23 %% Clean commands
24 commands() ->
25
:-(
[
26 [{name, inbox_flush_user_bin},
27 {category, <<"inbox">>},
28 {subcategory, <<"bin">>},
29 {desc, <<"Empty the bin for a user">>},
30 {module, ?MODULE},
31 {function, flush_user_bin},
32 {action, delete},
33 {identifiers, [domain, name, since]},
34 {args, [{domain, binary},
35 {name, binary},
36 {since, integer}]},
37 {result, {num, integer}}],
38 [{name, inbox_flush_global_bin},
39 {category, <<"inbox">>},
40 {subcategory, <<"bin">>},
41 {desc, <<"Empty the inbox bin globally">>},
42 {module, ?MODULE},
43 {function, flush_global_bin},
44 {action, delete},
45 {identifiers, [host_type, since]},
46 {args, [{host_type, binary},
47 {since, integer}]},
48 {result, {num, integer}}]
49 ].
50
51 flush_user_bin(Domain, Name, Days) ->
52
:-(
{LU, LS} = jid:to_lus(jid:make_bare(Name, Domain)),
53
:-(
{ok, HostType} = mongoose_domain_api:get_host_type(LS),
54
:-(
Now = erlang:system_time(microsecond),
55
:-(
FromTS = mod_inbox_utils:calculate_ts_from(Now, Days),
56
:-(
mod_inbox_backend:empty_user_bin(HostType, LS, LU, FromTS).
57
58 flush_global_bin(HostType, Days) ->
59
:-(
Now = erlang:system_time(microsecond),
60
:-(
FromTS = mod_inbox_utils:calculate_ts_from(Now, Days),
61
:-(
mod_inbox_backend:empty_global_bin(HostType, FromTS).
Line Hits Source