Skip to content

Commit

Permalink
Revert "XOAUTH2 support for Outlook SMTP (#15062)" (#15067)
Browse files Browse the repository at this point in the history
  • Loading branch information
themylogin authored Dec 2, 2024
1 parent fb6a2c7 commit 231b96d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 77 deletions.
19 changes: 10 additions & 9 deletions src/middlewared/middlewared/plugins/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ class DenyNetworkActivity(Exception):
pass


class QueueItem:
class QueueItem(object):

def __init__(self, message):
self.attempts = 0
self.message = message


class MailQueue:
class MailQueue(object):

MAX_ATTEMPTS = 3
MAX_QUEUE_LIMIT = 20

Expand Down Expand Up @@ -71,7 +73,10 @@ class MailModel(sa.Model):


class MailService(ConfigService):

mail_queue = MailQueue()
oauth_access_token = None
oauth_access_token_expires_at = None

class Config:
datastore = 'system.email'
Expand All @@ -91,7 +96,6 @@ class Config:
Password('pass', null=True, required=True),
Dict(
'oauth',
Str('provider'),
Str('client_id'),
Str('client_secret'),
Password('refresh_token'),
Expand All @@ -115,7 +119,6 @@ async def mail_extend(self, cfg):
(
'replace', Dict(
'oauth',
Str('provider'),
Str('client_id', required=True),
Str('client_secret', required=True),
Password('refresh_token', required=True),
Expand Down Expand Up @@ -367,7 +370,7 @@ def read_json():
msg[key] = val

try:
if config['oauth'] and config['oauth']['provider'] == 'gmail':
if config['oauth']:
self.middleware.call_sync('mail.gmail_send', msg, config)
else:
server = self._get_smtp_server(config, message['timeout'], local_hostname=local_hostname)
Expand Down Expand Up @@ -426,9 +429,7 @@ def _get_smtp_server(self, config, timeout=300, local_hostname=None):
local_hostname=local_hostname)
if config['security'] == 'TLS':
server.starttls()
if config['oauth'] and config['oauth']['provider'] == 'outlook':
self.middleware.call_sync('mail.outlook_xoauth2', server, config)
elif config['smtp']:
if config['smtp']:
server.login(config['user'], config['pass'])

return server
Expand All @@ -440,7 +441,7 @@ def send_mail_queue(self):
for queue in list(mq.queue):
try:
config = self.middleware.call_sync('mail.config')
if config['oauth'] and config['oauth']['provider'] == 'gmail':
if config['oauth']:
self.middleware.call_sync('mail.gmail_send', queue.message, config)
else:
server = self._get_smtp_server(config)
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/mail_/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def gmail_initialize(self):

@private
def gmail_build_service(self, config):
if config["oauth"] and config["oauth"]["provider"] == "gmail":
if config["oauth"]:
return GmailService(config)

return None
Expand Down
67 changes: 0 additions & 67 deletions src/middlewared/middlewared/plugins/mail_/outlook.py

This file was deleted.

0 comments on commit 231b96d

Please sign in to comment.