./ct_report/coverage/mod_inbox_backend.COVER.html

1 %% Just a proxy interface module between the main mod_inbox module and
2 %% the backend modules (i.e. mod_inbox_rdbms).
3 -module(mod_inbox_backend).
4
5 -export([init/2,
6 get_inbox/4,
7 clear_inbox/3,
8 remove_domain/2,
9 set_inbox/6,
10 remove_inbox_row/2,
11 set_inbox_incr_unread/5,
12 get_inbox_unread/2,
13 get_entry_properties/2,
14 set_entry_properties/3,
15 reset_unread/3]).
16
17 -define(MAIN_MODULE, mod_inbox).
18
19 -callback init(HostType, Opts) -> ok when
20 HostType :: mongooseim:host_type(),
21 Opts :: gen_mod:module_opts().
22
23 -callback get_inbox(HostType, LUser, LServer, Params) -> mod_inbox:get_inbox_res() when
24 HostType :: mongooseim:host_type(),
25 LUser :: jid:luser(),
26 LServer :: jid:lserver(),
27 Params :: mod_inbox:get_inbox_params().
28
29 -callback clear_inbox(HostType, LUser, LServer) -> mod_inbox:write_res() when
30 HostType :: mongooseim:host_type(),
31 LUser :: jid:luser(),
32 LServer :: jid:lserver().
33
34 -callback remove_domain(HostType, LServer) -> ok when
35 HostType :: mongooseim:host_type(),
36 LServer :: jid:lserver().
37
38 -callback set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
39 mod_inbox:write_res() when
40 HostType :: mongooseim:host_type(),
41 InboxEntryKey :: mod_inbox:entry_key(),
42 Content :: binary(),
43 Count :: integer(),
44 MsgId :: binary(),
45 Timestamp :: integer().
46
47 -callback remove_inbox_row(HostType, InboxEntryKey) -> mod_inbox:write_res() when
48 HostType :: mongooseim:host_type(),
49 InboxEntryKey :: mod_inbox:entry_key().
50
51 -callback set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
52 mod_inbox:count_res() when
53 HostType :: mongooseim:host_type(),
54 InboxEntryKey :: mod_inbox:entry_key(),
55 Content :: binary(),
56 MsgId :: binary(),
57 Timestamp :: integer().
58
59 -callback reset_unread(HostType, InboxEntryKey, MsgId) -> mod_inbox:write_res() when
60 HostType :: mongooseim:host_type(),
61 InboxEntryKey :: mod_inbox:entry_key(),
62 MsgId :: binary().
63
64 -callback get_inbox_unread(HostType, InboxEntryKey) -> {ok, integer()} when
65 HostType :: mongooseim:host_type(),
66 InboxEntryKey :: mod_inbox:entry_key().
67
68 -callback get_entry_properties(HostType, InboxEntryKey) -> Ret when
69 HostType :: mongooseim:host_type(),
70 InboxEntryKey :: mod_inbox:entry_key(),
71 Ret :: mod_inbox:entry_properties() | nil().
72
73 -callback set_entry_properties(HostType, InboxEntryKey, Params) -> Ret when
74 HostType :: mongooseim:host_type(),
75 InboxEntryKey :: mod_inbox:entry_key(),
76 Params :: mod_inbox:entry_properties(),
77 Ret :: mod_inbox:entry_properties() | {error, binary()}.
78
79 -spec init(HostType, Opts) -> ok when
80 HostType :: mongooseim:host_type(),
81 Opts :: gen_mod:module_opts().
82 init(HostType, Opts) ->
83
:-(
mongoose_backend:init(HostType, ?MAIN_MODULE, callback_funs(), Opts),
84
:-(
Args = [HostType, Opts],
85
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
86
87 -spec get_inbox(HostType, LUser, LServer, Params) -> mod_inbox:get_inbox_res() when
88 HostType :: mongooseim:host_type(),
89 LUser :: jid:luser(),
90 LServer :: jid:lserver(),
91 Params :: mod_inbox:get_inbox_params().
92 get_inbox(HostType, LUser, LServer, Params) ->
93
:-(
Args = [HostType, LUser, LServer, Params],
94
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
95
96 -spec clear_inbox(HostType, LUser, LServer) -> mod_inbox:write_res() when
97 HostType :: mongooseim:host_type(),
98 LUser :: jid:luser(),
99 LServer :: jid:lserver().
100 clear_inbox(HostType, LUser, LServer) ->
101
:-(
Args = [HostType, LUser, LServer],
102
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
103
104 -spec remove_domain(HostType, LServer) -> ok when
105 HostType :: mongooseim:host_type(),
106 LServer :: jid:lserver().
107 remove_domain(HostType, LServer) ->
108
:-(
Args = [HostType, LServer],
109
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
110
111 -spec set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
112 mod_inbox:write_res() when
113 HostType :: mongooseim:host_type(),
114 InboxEntryKey :: mod_inbox:entry_key(),
115 Content :: binary(),
116 Count :: integer(),
117 MsgId :: binary(),
118 Timestamp :: integer().
119 set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
120
:-(
Args = [HostType, InboxEntryKey, Content, Count, MsgId, Timestamp],
121
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
122
123 -spec remove_inbox_row(HostType, InboxEntryKey) -> mod_inbox:write_res() when
124 HostType :: mongooseim:host_type(),
125 InboxEntryKey :: mod_inbox:entry_key().
126 remove_inbox_row(HostType, InboxEntryKey) ->
127
:-(
Args = [HostType, InboxEntryKey],
128
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
129
130 -spec set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
131 mod_inbox:count_res() when
132 HostType :: mongooseim:host_type(),
133 InboxEntryKey :: mod_inbox:entry_key(),
134 Content :: binary(),
135 MsgId :: binary(),
136 Timestamp :: integer().
137 set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
138
:-(
Args = [HostType, InboxEntryKey, Content, MsgId, Timestamp],
139
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
140
141 -spec reset_unread(HostType, InboxEntryKey, MsgId) -> mod_inbox:write_res() when
142 HostType :: mongooseim:host_type(),
143 InboxEntryKey :: mod_inbox:entry_key(),
144 MsgId :: binary() | undefined.
145 reset_unread(HostType, InboxEntryKey, MsgId) ->
146
:-(
Args = [HostType, InboxEntryKey, MsgId],
147
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
148
149 -spec get_inbox_unread(HostType, InboxEntryKey) -> {ok, integer()} when
150 HostType :: mongooseim:host_type(),
151 InboxEntryKey :: mod_inbox:entry_key().
152 get_inbox_unread(HostType, InboxEntryKey) ->
153
:-(
Args = [HostType, InboxEntryKey],
154
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
155
156 -spec get_entry_properties(HostType, InboxEntryKey) -> Ret when
157 HostType :: mongooseim:host_type(),
158 InboxEntryKey :: mod_inbox:entry_key(),
159 Ret :: mod_inbox:entry_properties() | nil().
160 get_entry_properties(HostType, InboxEntryKey) ->
161
:-(
Args = [HostType, InboxEntryKey],
162
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
163
164 -spec set_entry_properties(HostType, InboxEntryKey, Params) -> Ret when
165 HostType :: mongooseim:host_type(),
166 InboxEntryKey :: mod_inbox:entry_key(),
167 Params :: mod_inbox:entry_properties(),
168 Ret :: mod_inbox:entry_properties() | {error, binary()}.
169 set_entry_properties(HostType, InboxEntryKey, Params) ->
170
:-(
Args = [HostType, InboxEntryKey, Params],
171
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
172
173 callback_funs() ->
174
:-(
[get_inbox, set_inbox, set_inbox_incr_unread,
175 reset_unread, remove_inbox_row, clear_inbox, get_inbox_unread,
176 get_entry_properties, set_entry_properties, remove_domain].
Line Hits Source