diff --git a/src-ui/src/app/components/manage/mail/mail.component.html b/src-ui/src/app/components/manage/mail/mail.component.html index c12e41782..84fbb3f84 100644 --- a/src-ui/src/app/components/manage/mail/mail.component.html +++ b/src-ui/src/app/components/manage/mail/mail.component.html @@ -41,8 +41,8 @@ diff --git a/src-ui/src/app/components/manage/mail/mail.component.spec.ts b/src-ui/src/app/components/manage/mail/mail.component.spec.ts index a69feef1b..34db62b7e 100644 --- a/src-ui/src/app/components/manage/mail/mail.component.spec.ts +++ b/src-ui/src/app/components/manage/mail/mail.component.spec.ts @@ -50,7 +50,7 @@ import { SettingsService } from 'src/app/services/settings.service' const mailAccounts = [ { id: 1, name: 'account1', account_type: MailAccountType.IMAP }, { id: 2, name: 'account2', account_type: MailAccountType.IMAP }, - { id: 3, name: 'account3', accout_type: MailAccountType.Gmail }, + { id: 3, name: 'account3', accout_type: MailAccountType.Gmail_OAuth }, ] const mailRules = [ { id: 1, name: 'rule1', owner: 1, account: 1, enabled: true }, diff --git a/src-ui/src/app/data/mail-account.ts b/src-ui/src/app/data/mail-account.ts index 81c3c57d2..bde9dbf88 100644 --- a/src-ui/src/app/data/mail-account.ts +++ b/src-ui/src/app/data/mail-account.ts @@ -8,8 +8,8 @@ export enum IMAPSecurity { export enum MailAccountType { IMAP = 1, - Gmail = 2, - Outlook = 3, + Gmail_OAuth = 2, + Outlook_OAuth = 3, } export interface MailAccount extends ObjectWithPermissions { diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index c4de9c3ab..9b3ac73d5 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -432,7 +432,7 @@ def refresh_oauth_token(account: MailAccount) -> bool: logger.error(f"Account {account}: No refresh token available.") return False - if account.account_type == MailAccount.MailAccountType.GMAIL: + if account.account_type == MailAccount.MailAccountType.GMAIL_OAUTH: url = "https://accounts.google.com/o/oauth2/token" data = { "client_id": settings.GMAIL_OAUTH_CLIENT_ID, @@ -440,7 +440,7 @@ def refresh_oauth_token(account: MailAccount) -> bool: "refresh_token": account.refresh_token, "grant_type": "refresh_token", } - elif account.account_type == MailAccount.MailAccountType.OUTLOOK: + elif account.account_type == MailAccount.MailAccountType.OUTLOOK_OAUTH: url = "https://login.microsoftonline.com/common/oauth2/v2.0/token" data = { "client_id": settings.OUTLOOK_OAUTH_CLIENT_ID, diff --git a/src/paperless_mail/migrations/0027_mailaccount_expiration_mailaccount_account_type_and_more.py b/src/paperless_mail/migrations/0027_mailaccount_expiration_mailaccount_account_type_and_more.py index 8dd7fe618..a39455b0f 100644 --- a/src/paperless_mail/migrations/0027_mailaccount_expiration_mailaccount_account_type_and_more.py +++ b/src/paperless_mail/migrations/0027_mailaccount_expiration_mailaccount_account_type_and_more.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): model_name="mailaccount", name="account_type", field=models.PositiveIntegerField( - choices=[(1, "IMAP"), (2, "Gmail"), (3, "Outlook")], + choices=[(1, "IMAP"), (2, "Gmail OAuth"), (3, "Outlook OAuth")], default=1, verbose_name="account type", ), diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py index 0ffce38bf..15f7bef35 100644 --- a/src/paperless_mail/models.py +++ b/src/paperless_mail/models.py @@ -17,8 +17,8 @@ class MailAccount(document_models.ModelWithOwner): class MailAccountType(models.IntegerChoices): IMAP = 1, _("IMAP") - GMAIL = 2, _("Gmail") - OUTLOOK = 3, _("Outlook") + GMAIL_OAUTH = 2, _("Gmail OAuth") + OUTLOOK_OAUTH = 3, _("Outlook OAuth") name = models.CharField(_("name"), max_length=256, unique=True) diff --git a/src/paperless_mail/tests/test_mail_oauth.py b/src/paperless_mail/tests/test_mail_oauth.py index a0a7efba4..c49df49f6 100644 --- a/src/paperless_mail/tests/test_mail_oauth.py +++ b/src/paperless_mail/tests/test_mail_oauth.py @@ -109,7 +109,7 @@ class TestMailOAuth( username="test_username", imap_security=MailAccount.ImapSecurity.SSL, imap_port=993, - account_type=MailAccount.MailAccountType.GMAIL, + account_type=MailAccount.MailAccountType.GMAIL_OAUTH, is_token=True, refresh_token="test_refresh_token", expiration=timezone.now() - timedelta(days=1), diff --git a/src/paperless_mail/views.py b/src/paperless_mail/views.py index e84e3b8e4..58c5d6f28 100644 --- a/src/paperless_mail/views.py +++ b/src/paperless_mail/views.py @@ -112,7 +112,7 @@ class OauthCallbackView(GenericAPIView): if scope is not None and "google" in scope: # Google # Gmail setup guide: https://postmansmtp.com/how-to-configure-post-smtp-with-gmailgsuite-using-oauth/ - account_type = MailAccount.MailAccountType.GMAIL + account_type = MailAccount.MailAccountType.GMAIL_OAUTH imap_server = "imap.gmail.com" defaults = { "name": f"Gmail OAuth {timezone.now()}", @@ -129,7 +129,7 @@ class OauthCallbackView(GenericAPIView): elif scope is None: # Outlook # Outlok setup guide: https://medium.com/@manojkumardhakad/python-read-and-send-outlook-mail-using-oauth2-token-and-graph-api-53de606ecfa1 - account_type = MailAccount.MailAccountType.OUTLOOK + account_type = MailAccount.MailAccountType.OUTLOOK_OAUTH imap_server = "outlook.office365.com" defaults = { "name": f"Outlook OAuth {timezone.now()}",