./ct_report/coverage/mod_event_pusher_push_backend.COVER.html

1 %%%-------------------------------------------------------------------
2 %%% @copyright 2021, Erlang Solutions Ltd.
3 %%% @doc A proxy interface module between the mod_event_pusher_push
4 %%% module and the backend modules.
5 %%%
6 %%% @end
7 %%%-------------------------------------------------------------------
8 -module(mod_event_pusher_push_backend).
9
10 -export([init/2,
11 enable/5,
12 disable/2,
13 disable/4,
14 get_publish_services/2]).
15
16 -define(MAIN_MODULE, mod_event_pusher_push).
17
18 %%--------------------------------------------------------------------
19 %% DB backend behaviour definition
20 %%--------------------------------------------------------------------
21
22 -callback init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
23
24 -callback enable(mongooseim:host_type(), UserJID :: jid:jid(), PubsubJID :: jid:jid(),
25 Node :: mod_event_pusher_push:pubsub_node(),
26 Form :: mod_event_pusher_push:form()) ->
27 ok | {error, Reason :: term()}.
28
29 -callback disable(mongooseim:host_type(), UserJID :: jid:jid()) ->
30 ok | {error, Reason :: term()}.
31
32 -callback disable(mongooseim:host_type(), UserJID :: jid:jid(), PubsubJID :: jid:jid(),
33 Node :: mod_event_pusher_push:pubsub_node() | undefined) ->
34 ok | {error, Reason :: term()}.
35
36 -callback get_publish_services(mongooseim:host_type(), UserJID :: jid:jid()) ->
37 {ok, [mod_event_pusher_push:publish_service()]} | {error, Reason :: term()}.
38
39 %% API
40
41 -spec init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
42 init(HostType, Opts) ->
43
:-(
TrackedFuns = [enable, disable, get_publish_services],
44
:-(
mongoose_backend:init(HostType, ?MAIN_MODULE, TrackedFuns, Opts),
45
:-(
Args = [HostType, Opts],
46
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
47
48 -spec enable(mongooseim:host_type(),
49 UserJID :: jid:jid(), PubsubJID :: jid:jid(),
50 Node :: mod_event_pusher_push:pubsub_node(),
51 Form :: mod_event_pusher_push:form()) ->
52 ok | {error, Reason :: term()}.
53 enable(HostType, UserJID, PubsubJID, Node, Form) ->
54
:-(
Args = [HostType, UserJID, PubsubJID, Node, Form],
55
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
56
57 -spec disable(mongooseim:host_type(), UserJID :: jid:jid()) ->
58 ok | {error, Reason :: term()}.
59 disable(HostType, UserJID) ->
60
:-(
Args = [HostType, UserJID],
61
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
62
63 -spec disable(mongooseim:host_type(), UserJID :: jid:jid(), PubsubJID :: jid:jid(),
64 Node :: mod_event_pusher_push:pubsub_node() | undefined) ->
65 ok | {error, Reason :: term()}.
66 disable(HostType, UserJID, PubsubJID, Node) ->
67
:-(
Args = [HostType, UserJID, PubsubJID, Node],
68
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
69
70 -spec get_publish_services(mongooseim:host_type(), User :: jid:jid()) ->
71 {ok, [mod_event_pusher_push:publish_service()]} | {error, Reason :: term()}.
72 get_publish_services(HostType, User) ->
73
:-(
Args = [HostType, User],
74
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source