./ct_report/coverage/mod_mam_params.COVER.html

1 %%==============================================================================
2 %% Copyright 2018 Erlang Solutions Ltd.
3 %%
4 %% Licensed under the Apache License, Version 2.0 (the "License");
5 %% you may not use this file except in compliance with the License.
6 %% You may obtain a copy of the License at
7 %%
8 %% http://www.apache.org/licenses/LICENSE-2.0
9 %%
10 %% Unless required by applicable law or agreed to in writing, software
11 %% distributed under the License is distributed on an "AS IS" BASIS,
12 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 %% See the License for the specific language governing permissions and
14 %% limitations under the License.
15 %%==============================================================================
16
17 -module(mod_mam_params).
18
19 -type mam_module() :: mod_mam | mod_mam_muc.
20
21 -export([extra_params_module/2, max_result_limit/2, default_result_limit/2,
22 has_full_text_search/2, is_archivable_message_fun/2, send_message_mod/2,
23 archive_chat_markers/2, add_stanzaid_element/2, extra_fin_element_module/2]).
24
25 %%--------------------------------------------------------------------
26 %% API
27 %%--------------------------------------------------------------------
28
29 -spec extra_params_module(mam_module(), mongooseim:host_type()) -> module() | undefined.
30 extra_params_module(Module, HostType) ->
31
:-(
param(Module, HostType, extra_lookup_params, undefined).
32
33 -spec max_result_limit(mam_module(), mongooseim:host_type()) -> pos_integer().
34 max_result_limit(Module, HostType) ->
35
:-(
param(Module, HostType, max_result_limit, 50).
36
37 -spec default_result_limit(mam_module(), mongooseim:host_type()) -> pos_integer().
38 default_result_limit(Module, HostType) ->
39
:-(
param(Module, HostType, default_result_limit, 50).
40
41
42 -spec has_full_text_search(Module :: mod_mam | mod_mam_muc, mongooseim:host_type()) -> boolean().
43 has_full_text_search(Module, HostType) ->
44
:-(
param(Module, HostType, full_text_search, true).
45
46 -spec is_archivable_message_fun(mam_module(), mongooseim:host_type()) ->
47 MF :: {module(), atom()}.
48 is_archivable_message_fun(Module, HostType) ->
49
:-(
{IsArchivableModule, IsArchivableFunction} =
50 case param(Module, HostType, is_archivable_message, undefined) of
51 undefined ->
52
:-(
case param(Module, HostType, is_complete_message, undefined) of
53
:-(
undefined -> {mod_mam_utils, is_archivable_message};
54
:-(
OldStyleMod -> {OldStyleMod, is_complete_message}
55 end;
56
57
:-(
Mod -> {Mod, is_archivable_message}
58 end,
59
:-(
{IsArchivableModule, IsArchivableFunction}.
60
61 -spec send_message_mod(mam_module(), mongooseim:host_type()) -> module().
62 send_message_mod(Module, HostType) ->
63
:-(
param(Module, HostType, send_message, mod_mam_utils).
64
65 -spec archive_chat_markers(mam_module(), mongooseim:host_type()) -> boolean().
66 archive_chat_markers(Module, HostType) ->
67
:-(
param(Module, HostType, archive_chat_markers, false).
68
69 -spec add_stanzaid_element(mam_module(), mongooseim:host_type()) -> boolean().
70 add_stanzaid_element(Module, HostType) ->
71
:-(
not param(Module, HostType, no_stanzaid_element, false).
72
73 -spec extra_fin_element_module(mam_module(), mongooseim:host_type()) -> module() | undefined.
74 extra_fin_element_module(Module, HostType) ->
75
:-(
param(Module, HostType, extra_fin_element, undefined).
76
77 %%--------------------------------------------------------------------
78 %% Internal functions
79 %%--------------------------------------------------------------------
80
81 -spec param(mam_module(), mongooseim:host_type(), Opt :: term(), Default :: term()) -> term().
82 param(Module, HostType, Opt, Default) ->
83
:-(
gen_mod:get_module_opt(HostType, Module, Opt, Default).
Line Hits Source