mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 00:23:43 +08:00
56718504ac
While we are unable to support OAUTH2 with pop3 (due to upstream dependency ruby/net-pop#16), we are adding the support for mail pollers plugin. 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 a poll_mailbox static method which returns an array of strings. Then the plugin could call register_mail_poller(<class_name>) to have it registered. All the configuration (oauth2 tokens, email, etc) could be managed by sitesettings defined in the plugin.
19 lines
534 B
Ruby
19 lines
534 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Email
|
|
class Poller
|
|
# To be implemented by concrete classes.
|
|
# This function takes as input a function that processes the incoming email.
|
|
# The function passed as argument should take as an argument the MIME string of the email.
|
|
# An example of function to pass is `process_popmail` in `app/jobs/scheduled/poll_mailbox.rb`
|
|
def poll_mailbox(process_cb)
|
|
raise NotImplementedError
|
|
end
|
|
|
|
# Child class can override this
|
|
def enabled?
|
|
true
|
|
end
|
|
end
|
|
end
|