./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(Host :: jid:server(), Opts :: list()) -> ok.
23
24 -callback enable(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(UserJID :: jid:jid()) ->
30 ok | {error, Reason :: term()}.
31
32 -callback disable(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(User :: jid:jid()) ->
37 {ok, [mod_event_pusher_push:publish_service()]} | {error, Reason :: term()}.
38
39
40 -spec init(Host :: jid:server(), Opts :: list()) -> ok.
41 init(Host, Opts) ->
42 16 TrackedFuns = [enable, disable, get_publish_services],
43 16 mongoose_backend:init(Host, ?MAIN_MODULE, TrackedFuns, Opts),
44 16 Args = [Host, Opts],
45 16 mongoose_backend:call(Host, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
46
47 -spec enable(Host :: jid:server(),
48 UserJID :: jid:jid(), PubsubJID :: jid:jid(),
49 Node :: mod_event_pusher_push:pubsub_node(),
50 Form :: mod_event_pusher_push:form()) ->
51 ok | {error, Reason :: term()}.
52 enable(Host, UserJID, PubsubJID, Node, Form) ->
53 86 Args = [UserJID, PubsubJID, Node, Form],
54 86 mongoose_backend:call_tracked(Host, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
55
56 -spec disable(Host :: jid:server(), UserJID :: jid:jid()) ->
57 ok | {error, Reason :: term()}.
58 disable(Host, UserJID) ->
59 2 Args = [UserJID],
60 2 mongoose_backend:call_tracked(Host, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
61
62 -spec disable(Host :: jid:server(), UserJID :: jid:jid(), PubsubJID :: jid:jid(),
63 Node :: mod_event_pusher_push:pubsub_node() | undefined) ->
64 ok | {error, Reason :: term()}.
65 disable(Host, UserJID, PubsubJID, Node) ->
66 11 Args = [UserJID, PubsubJID, Node],
67 11 mongoose_backend:call_tracked(Host, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
68
69 -spec get_publish_services(Host :: jid:server(), User :: jid:jid()) ->
70 {ok, [mod_event_pusher_push:publish_service()]} | {error, Reason :: term()}.
71 get_publish_services(Host, User) ->
72 150 Args = [User],
73 150 mongoose_backend:call_tracked(Host, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Line Hits Source