Skip to content

Commit

Permalink
Add maybe_pm_hooks function for cache_user/rdbms_prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Jun 17, 2021
1 parent ea1cec1 commit 5ff96d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
19 changes: 7 additions & 12 deletions src/mam/mod_mam_cache_user.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,13 @@ start_server() ->
hooks(HostType) ->
PM = gen_mod:get_module_opt(HostType, ?MODULE, pm, false),
MUC = gen_mod:get_module_opt(HostType, ?MODULE, muc, false),
case PM of
true ->
pm_hooks(HostType);
false ->
[]
end ++
case MUC of
true ->
muc_hooks(HostType);
false ->
[]
end.
maybe_pm_hooks(PM, HostType) ++ maybe_muc_hooks(MUC, HostType).

maybe_pm_hooks(true, HostType) -> pm_hooks(HostType);
maybe_pm_hooks(false, _HostType) -> [].

maybe_muc_hooks(true, HostType) -> muc_hooks(HostType);
maybe_muc_hooks(false, _HostType) -> [].

pm_hooks(HostType) ->
[{mam_archive_id, HostType, ?MODULE, cached_archive_id, 30},
Expand Down
15 changes: 7 additions & 8 deletions src/mam/mod_mam_rdbms_prefs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ stop(HostType) ->
hooks(HostType) ->
PM = gen_mod:get_module_opt(HostType, ?MODULE, pm, false),
MUC = gen_mod:get_module_opt(HostType, ?MODULE, muc, false),
case PM of
true -> pm_hooks(HostType);
false -> []
end ++
case MUC of
true -> muc_hooks(HostType);
false -> []
end.
maybe_pm_hooks(PM, HostType) ++ maybe_muc_hooks(MUC, HostType).

maybe_pm_hooks(true, HostType) -> pm_hooks(HostType);
maybe_pm_hooks(false, _HostType) -> [].

maybe_muc_hooks(true, HostType) -> muc_hooks(HostType);
maybe_muc_hooks(false, _HostType) -> [].

pm_hooks(HostType) ->
[{mam_get_behaviour, HostType, ?MODULE, get_behaviour, 50},
Expand Down

0 comments on commit 5ff96d7

Please sign in to comment.