./ct_report/coverage/mod_offline_chatmarkers_backend.COVER.html

1 %% Just a proxy interface module between the main mod_offline_chatmarkers module and
2 %% the backend modules (i.e. mod_offline_chatmarkers_rdbms...).
3 -module(mod_offline_chatmarkers_backend).
4
5 -export([init/2,
6 get/2,
7 maybe_store/5,
8 remove_user/2]).
9
10 -define(MAIN_MODULE, mod_offline_chatmarkers).
11
12 -callback init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
13 -callback get(mongooseim:host_type(), jid:jid()) -> {ok, [{Thread :: undefined | binary(),
14 Room :: undefined | jid:jid(),
15 Timestamp :: integer()}]}.
16
17 %%% Jid, Thread, and Room parameters serve as a composite database key. If
18 %%% key is not available in the database, then it must be added with the
19 %%% corresponding timestamp. Otherwise this function does nothing, the stored
20 %%% timestamp for the composite key MUST remain unchanged!
21 -callback maybe_store(mongooseim:host_type(), Jid :: jid:jid(), Thread :: undefined | binary(),
22 Room :: undefined | jid:jid(), Timestamp :: integer()) -> ok.
23 -callback remove_user(mongooseim:host_type(), Jid :: jid:jid()) -> ok.
24
25 -spec init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
26 init(HostType, Opts) ->
27
:-(
mongoose_backend:init(HostType, ?MAIN_MODULE, [get, maybe_store], Opts),
28
:-(
Args = [HostType, Opts],
29
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
30
31 -spec get(mongooseim:host_type(), jid:jid()) -> {ok, [{Thread :: undefined | binary(),
32 Room :: undefined | jid:jid(),
33 Timestamp :: integer()}]}.
34 get(HostType, UserJID) ->
35
:-(
Args = [HostType, UserJID],
36
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
37
38 -spec maybe_store(mongooseim:host_type(), Jid :: jid:jid(), Thread :: undefined | binary(),
39 Room :: undefined | jid:jid(), Timestamp :: integer()) -> ok.
40 maybe_store(HostType, UserJID, Thread, Room, Timestamp) ->
41
:-(
Args = [HostType, UserJID, Thread, Room, Timestamp],
42
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
43
44 -spec remove_user(mongooseim:host_type(), Jid :: jid:jid()) -> ok.
45 remove_user(HostType, UserJID) ->
46
:-(
Args = [HostType, UserJID],
47
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source