Skip to content
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

fix: plugin names: removing 'haraka-plugin-' from plugin names breaks… #2867

Closed
wants to merge 3 commits into from

Conversation

AuspeXeu
Copy link
Contributor

@AuspeXeu AuspeXeu commented Dec 3, 2020

… with plugins 'known-senders' and 'recipient-routes' enabled (at least, maybe more); look up plugin by actual name when running hooks

… with plugins 'known-senders' and 'recipient-routes' enabled (at least, maybe more); lookup plugin by actual name when running hooks
@msimerson
Copy link
Member

msimerson commented Dec 3, 2020

You should define what "by actual name" means. Also, this seems like a PR that definitely should have a test or three to better define the behavior.

related to #2846

@AuspeXeu
Copy link
Contributor Author

AuspeXeu commented Dec 4, 2020

I don't think I have the depth of understanding for this code base to actually know what to test here but basically this PR fixes #2870 which seems to be some sort of regression on how plugin names are handled.

@msimerson
Copy link
Member

Okay, I'll poke at it when I get some free cycles. I think it's best to get the plugins loading whether referenced by their short name, and take that into account when parsing the list of plugins to load.

@msimerson
Copy link
Member

I've looked at this again and honestly, the underlying problem is that:

• we (the authors of Haraka that added support for NPM packaged plugins) always assumed that plugins would be listed in the config/plugins file without the haraka-plugin prefix.
• you expect that plugins should be listed on config/plugins with the haraka-plugin prefix.

I think this will fix the discrepancy.

 ✗ git diff plugins.js
diff --git a/plugins.js b/plugins.js
index 9dea5142..aff49d2b 100644
--- a/plugins.js
+++ b/plugins.js
@@ -320,6 +320,7 @@ plugins.load_plugins = override => {
     }
 
     plugin_list.forEach(plugin => {
+        if (plugin.substr(0,14) === 'haraka-plugin-') plugin = plugin.substr(14)
         if (plugins.deprecated[plugin]) {
             logger.lognotice(`the plugin ${plugin} has been replaced by '${plugins.deprecated[plugin]}'. Please update config/plugins`)
             plugins.load_plugin(plugins.deprecated[plugin]);

@AuspeXeu
Copy link
Contributor Author

AuspeXeu commented Dec 4, 2020

I guess I assumed that whenever I would write a plugin called my-awesome-plugin I would add that full name into the plugins config. Hence I would do the same for haraka-plugin- prefixed ones. I think your suggestion to strip it from the config is a good way forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants