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
Add hooks for email poller plugins #21384
Conversation
3803416
to
18910a0
Compare
I've slightly changed the design of the API. Now discourse core gives a callback to the plugin to call each time to process an inbound mail. I thought this was the best idea to easily give the control over the lifecycle of an email to the plugin. |
862e7c7
to
08111a7
Compare
08111a7
to
e310f9e
Compare
the biggest thing missing here is some tests, we are adding an extensibility point here, if we don't cover it with tests we are more likely to mistakenly remove or break it in future. |
e310f9e
to
74ef5a9
Compare
I've added a couple of tests, let me know if you think we should add more, thanks! |
79d7fcd
to
a017563
Compare
8a9461f
to
6002f02
Compare
I saw that the PR failed, the error didn't look like it was something related to my changes. I rebased again and pushed |
6002f02
to
36c4e1a
Compare
Hello, I've added the fact that now the validator for |
bf3cc7e
to
f5705b8
Compare
With the following configuration, we've been able to reply by mail (private message included) and send an email to a category with successful results: Settings (core)
Settings (plugin)
Emails are automatically auto-purged from Exchange Online, which is great. Unless Discourse Team gives us some more feedback, this is ready. |
This pull request has been mentioned on Discourse Meta. There might be relevant details there: https://meta.discourse.org/t/microsoft-graph-mail-poller/268611/1 |
def self.register_mail_poller(mail_poller) | ||
self.mail_pollers << mail_poller | ||
end |
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.
Just need a small test in https://github.com/discourse/discourse/blob/main/spec/lib/discourse_plugin_registry_spec.rb. Ideally we want to test the empty set.
If you could add an explicit empty test in poll_mailbox_spec.rb
describe "poller plugin"
that would be good too - though I get that it would be covered implicitly in the tests above.
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.
Thanks, I added the test for the empty set!
Heya @AlessioC31, took this for a spin locally! This generally looks very good, thanks. I'll be happy to approve this with one small addition. Will keep this PR open 👀 so we can get this in this week. |
f5705b8
to
9629963
Compare
9629963
to
4b4a143
Compare
Very funny/shady but the test failure is mailer related but has got nothing to do with your change. Will re-run
|
Hello,
This PR is child of #20445: while it would be better to support OAUTH2 with pop3, that PR can't be merged until pop3 merges the support for XOAUTH (ruby/net-pop#16).
For this reason, I would like to add in discourse the support for mail pollers plugins. Doing so, it would be possible to write a plugin which then uses other ways (microsoft graph sdk for example) to poll emails from a mailbox.
The idea is that a plugin would define a class which inherits from
Email::Poller
and defines apoll_mailbox
static method which returns an array of strings. Then the plugin could callregister_mail_poller(<class_name>)
to have it registered. All the configuration (oauth2 tokens, email, etc) could be managed by sitesettings defined in the plugin.Please let me know if this solution works for you (I tried to have a look at other "plugin hooks" and based my solution on those) and if you think I should change something, thanks!