./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 -include("mod_inbox.hrl").
6
7 -export([init/2,
8 get_inbox/4,
9 clear_inbox/3,
10 remove_domain/2,
11 set_inbox/6,
12 remove_inbox_row/2,
13 empty_user_bin/4,
14 empty_global_bin/2,
15 set_inbox_incr_unread/5,
16 get_inbox_unread/2,
17 get_full_entry/2,
18 get_entry_properties/2,
19 set_entry_properties/3,
20 reset_unread/4]).
21
22 -define(MAIN_MODULE, mod_inbox).
23
24 -callback init(HostType, Opts) -> ok when
25 HostType :: mongooseim:host_type(),
26 Opts :: gen_mod:module_opts().
27
28 -callback get_inbox(HostType, LUser, LServer, Params) -> [mod_inbox:inbox_res()] when
29 HostType :: mongooseim:host_type(),
30 LUser :: jid:luser(),
31 LServer :: jid:lserver(),
32 Params :: mod_inbox:get_inbox_params().
33
34 -callback clear_inbox(HostType, LUser, LServer) -> mod_inbox:write_res() when
35 HostType :: mongooseim:host_type(),
36 LUser :: jid:luser(),
37 LServer :: jid:lserver().
38
39 -callback remove_domain(HostType, LServer) -> ok when
40 HostType :: mongooseim:host_type(),
41 LServer :: jid:lserver().
42
43 -callback set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
44 mod_inbox:write_res() when
45 HostType :: mongooseim:host_type(),
46 InboxEntryKey :: mod_inbox:entry_key(),
47 Content :: exml:element(),
48 Count :: integer(),
49 MsgId :: binary(),
50 Timestamp :: integer().
51
52 -callback remove_inbox_row(HostType, InboxEntryKey) -> mod_inbox:write_res() when
53 HostType :: mongooseim:host_type(),
54 InboxEntryKey :: mod_inbox:entry_key().
55
56 -callback empty_user_bin(HostType, LServer, LUser, TS) -> non_neg_integer() when
57 HostType :: mongooseim:host_type(),
58 LServer :: jid:lserver(),
59 LUser :: jid:luser(),
60 TS :: integer().
61
62 -callback empty_global_bin(HostType, TS) -> non_neg_integer() when
63 HostType :: mongooseim:host_type(),
64 TS :: integer().
65
66 -callback set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
67 mod_inbox:count_res() when
68 HostType :: mongooseim:host_type(),
69 InboxEntryKey :: mod_inbox:entry_key(),
70 Content :: exml:element(),
71 MsgId :: binary(),
72 Timestamp :: integer().
73
74 -callback reset_unread(HostType, InboxEntryKey, MsgId, TS) -> mod_inbox:write_res() when
75 HostType :: mongooseim:host_type(),
76 InboxEntryKey :: mod_inbox:entry_key(),
77 MsgId :: binary() | undefined,
78 TS :: integer().
79
80 -callback get_inbox_unread(HostType, InboxEntryKey) -> {ok, integer()} when
81 HostType :: mongooseim:host_type(),
82 InboxEntryKey :: mod_inbox:entry_key().
83
84 -callback get_full_entry(HostType, InboxEntryKey) -> Ret when
85 HostType :: mongooseim:host_type(),
86 InboxEntryKey :: mod_inbox:entry_key(),
87 Ret :: inbox_res() | nil().
88
89 -callback get_entry_properties(HostType, InboxEntryKey) -> Ret when
90 HostType :: mongooseim:host_type(),
91 InboxEntryKey :: mod_inbox:entry_key(),
92 Ret :: mod_inbox:entry_properties() | nil().
93
94 -callback set_entry_properties(HostType, InboxEntryKey, Params) -> Ret when
95 HostType :: mongooseim:host_type(),
96 InboxEntryKey :: mod_inbox:entry_key(),
97 Params :: mod_inbox:entry_properties(),
98 Ret :: mod_inbox:entry_properties() | {error, binary()}.
99
100 -spec init(HostType, Opts) -> ok when
101 HostType :: mongooseim:host_type(),
102 Opts :: gen_mod:module_opts().
103 init(HostType, Opts) ->
104
:-(
mongoose_backend:init(HostType, ?MAIN_MODULE, callback_funs(), Opts),
105
:-(
Args = [HostType, Opts],
106
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
107
108 -spec get_inbox(HostType, LUser, LServer, Params) -> [mod_inbox:inbox_res()] when
109 HostType :: mongooseim:host_type(),
110 LUser :: jid:luser(),
111 LServer :: jid:lserver(),
112 Params :: mod_inbox:get_inbox_params().
113 get_inbox(HostType, LUser, LServer, Params) ->
114
:-(
Args = [HostType, LUser, LServer, Params],
115
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
116
117 -spec clear_inbox(HostType, LUser, LServer) -> mod_inbox:write_res() when
118 HostType :: mongooseim:host_type(),
119 LUser :: jid:luser(),
120 LServer :: jid:lserver().
121 clear_inbox(HostType, LUser, LServer) ->
122
:-(
Args = [HostType, LUser, LServer],
123
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
124
125 -spec remove_domain(HostType, LServer) -> ok when
126 HostType :: mongooseim:host_type(),
127 LServer :: jid:lserver().
128 remove_domain(HostType, LServer) ->
129
:-(
Args = [HostType, LServer],
130
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
131
132 -spec set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
133 mod_inbox:write_res() when
134 HostType :: mongooseim:host_type(),
135 InboxEntryKey :: mod_inbox:entry_key(),
136 Content :: exml:element(),
137 Count :: integer(),
138 MsgId :: binary(),
139 Timestamp :: integer().
140 set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
141
:-(
Args = [HostType, InboxEntryKey, Content, Count, MsgId, Timestamp],
142
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
143
144 -spec remove_inbox_row(HostType, InboxEntryKey) -> mod_inbox:write_res() when
145 HostType :: mongooseim:host_type(),
146 InboxEntryKey :: mod_inbox:entry_key().
147 remove_inbox_row(HostType, InboxEntryKey) ->
148
:-(
Args = [HostType, InboxEntryKey],
149
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
150
151 -spec empty_user_bin(HostType, LServer, LUser, TS) -> non_neg_integer() when
152 HostType :: mongooseim:host_type(),
153 LServer :: jid:lserver(),
154 LUser :: jid:luser(),
155 TS :: integer().
156 empty_user_bin(HostType, LServer, LUser, TS) ->
157
:-(
Args = [HostType, LServer, LUser, TS],
158
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
159
160 -spec empty_global_bin(HostType, TS) -> non_neg_integer() when
161 HostType :: mongooseim:host_type(),
162 TS :: integer().
163 empty_global_bin(HostType, TS) ->
164
:-(
Args = [HostType, TS],
165
:-(
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
166
167 -spec set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
168 mod_inbox:count_res() when
169 HostType :: mongooseim:host_type(),
170 InboxEntryKey :: mod_inbox:entry_key(),
171 Content :: exml:element(),
172 MsgId :: binary(),
173 Timestamp :: integer().
174 set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
175
:-(
Args = [HostType, InboxEntryKey, Content, MsgId, Timestamp],
176
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
177
178 -spec reset_unread(HostType, InboxEntryKey, MsgId, TS) -> mod_inbox:write_res() when
179 HostType :: mongooseim:host_type(),
180 InboxEntryKey :: mod_inbox:entry_key(),
181 MsgId :: binary() | undefined,
182 TS :: integer().
183 reset_unread(HostType, InboxEntryKey, MsgId, TS) ->
184
:-(
Args = [HostType, InboxEntryKey, MsgId, TS],
185
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
186
187 -spec get_inbox_unread(HostType, InboxEntryKey) -> {ok, integer()} when
188 HostType :: mongooseim:host_type(),
189 InboxEntryKey :: mod_inbox:entry_key().
190 get_inbox_unread(HostType, InboxEntryKey) ->
191
:-(
Args = [HostType, InboxEntryKey],
192
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
193
194 -spec get_full_entry(HostType, InboxEntryKey) -> Ret when
195 HostType :: mongooseim:host_type(),
196 InboxEntryKey :: mod_inbox:entry_key(),
197 Ret :: inbox_res() | nil().
198 get_full_entry(HostType, InboxEntryKey) ->
199
:-(
Args = [HostType, InboxEntryKey],
200
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
201
202 -spec get_entry_properties(HostType, InboxEntryKey) -> Ret when
203 HostType :: mongooseim:host_type(),
204 InboxEntryKey :: mod_inbox:entry_key(),
205 Ret :: mod_inbox:entry_properties() | nil().
206 get_entry_properties(HostType, InboxEntryKey) ->
207
:-(
Args = [HostType, InboxEntryKey],
208
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
209
210 -spec set_entry_properties(HostType, InboxEntryKey, Params) -> Ret when
211 HostType :: mongooseim:host_type(),
212 InboxEntryKey :: mod_inbox:entry_key(),
213 Params :: mod_inbox:entry_properties(),
214 Ret :: mod_inbox:entry_properties() | {error, binary()}.
215 set_entry_properties(HostType, InboxEntryKey, Params) ->
216
:-(
Args = [HostType, InboxEntryKey, Params],
217
:-(
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
218
219 callback_funs() ->
220
:-(
[get_inbox, set_inbox, set_inbox_incr_unread,
221 reset_unread, remove_inbox_row, clear_inbox, get_inbox_unread,
222 get_full_entry, get_entry_properties, set_entry_properties, remove_domain].
Line Hits Source