-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify MAM configuration #1112
Conversation
fun({Module, _Args}) -> | ||
gen_mod:stop_module(Host, Module) | ||
end, Modules); | ||
lists:foreach(fun({Mod, _}) -> gen_mod:stop_module(Host, Mod) end, Modules); | ||
handle_local_hosts_config_del({{Key,_}, _} =El) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Missing space right "," on line 1079
@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) -> | |||
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) -> | |||
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]); | |||
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) -> | |||
Res = compare_modules(OldModules, NewModules), | |||
reload_modules(Host, Res); | |||
gen_mod_deps:replace_modules(Host, OldModules, NewModules); | |||
handle_local_hosts_config_change({{Key,_Host},_Old,_New} = El) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Missing space right "," on line 1112
fun({Module, Args}) -> | ||
gen_mod:start_module(Host, Module, Args) | ||
end, Modules); | ||
gen_mod_deps:start_modules(Host, Modules); | ||
handle_local_hosts_config_add({{Key,_Host}, _} = El) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Missing space right "," on line 1054
@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) -> | |||
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) -> | |||
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]); | |||
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Missing space right "," on line 1110
@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) -> | |||
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) -> | |||
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]); | |||
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) -> | |||
Res = compare_modules(OldModules, NewModules), | |||
reload_modules(Host, Res); | |||
gen_mod_deps:replace_modules(Host, OldModules, NewModules); | |||
handle_local_hosts_config_change({{Key,_Host},_Old,_New} = El) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Missing space right "," on line 1112
@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) -> | |||
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) -> | |||
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]); | |||
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) -> | |||
Res = compare_modules(OldModules, NewModules), | |||
reload_modules(Host, Res); | |||
gen_mod_deps:replace_modules(Host, OldModules, NewModules); | |||
handle_local_hosts_config_change({{Key,_Host},_Old,_New} = El) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Missing space right "," on line 1112
If you haven't chosen any of the above, skip the next part. | ||
* **backend** (atom, default: `odbc`) - Database backend to use. `odbc`, `riak` and `cassandra` are supported. | ||
* **add_archived_element** (atom, default: `false`) - Add `<archived/>` element from MAM v0.2. | ||
* **is_complete_message** (module, default: `mod_mam_utils`) - Name of a module implementing [`is_complete_message/3` callback](#is_complete_message) that determines if the message should be archived. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's refactor this to is_archivable_message
, because complete
doesn't really makes sense IMO.
Deps = add_dep(mod_mam_odbc_user, [Type], Deps1), | ||
|
||
lists:foldl( | ||
fun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracting this fun
to a function will most probably improve readability here.
6833e15
to
f0b55d8
Compare
|
||
call_is_archivable_message(Module, Dir, Packet) -> | ||
M = mod_mam_muc_params:is_archivable_message(), | ||
M:is_archivable_message(Module, Dir, Packet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Remove the dynamic function call on line 985. Only modules that define callbacks should make dynamic calls.
M:is_complete_message(Module, Dir, Packet). | ||
is_archivable_message(Module, Dir, Packet) -> | ||
M = mod_mam_params:is_archivable_message(), | ||
M:is_archivable_message(Module, Dir, Packet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Remove the dynamic function call on line 1015. Only modules that define callbacks should make dynamic calls.
f0b55d8
to
1556966
Compare
|
||
call_is_archivable_message(Module, Dir, Packet) -> | ||
M = mod_mam_muc_params:is_archivable_message(), | ||
M:is_archivable_message(Module, Dir, Packet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Remove the dynamic function call on line 987. Only modules that define callbacks should make dynamic calls.
1556966
to
a56c567
Compare
|
||
call_is_archivable_message(Module, Dir, Packet) -> | ||
M = mod_mam_muc_params:is_archivable_message(), | ||
M:is_archivable_message(Module, Dir, Packet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Remove the dynamic function call on line 995. Only modules that define callbacks should make dynamic calls.
a56c567
to
6d75ad6
Compare
M = mod_mam_muc_params:is_complete_message(), | ||
M:is_complete_message(Module, Dir, Packet). | ||
|
||
call_is_archivable_message(Module, Dir, Packet) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Compiler:
Warning: function call_is_archivable_message/3 is unused
Configuration is simplified by introducing a new module, mod_mam_meta, that only parses its arguments and pulls in relevant MAM modules using deps/2 callback. This way a unified configuration may be introduced without disrupting existing modules and providing full backwards compatibility with old configs.
6d75ad6
to
73704e2
Compare
Configuration is simplified by introducing a new module, mod_mam_meta, that only parses its arguments and pulls in relevant MAM modules using deps/2 callback introduced in #1103. This way a unified configuration may be introduced without disrupting existing modules and providing full backwards compatibility with old configs.