-
-
-
+
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 d3194459f..5f9a3c73a 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
@@ -219,6 +219,23 @@ describe('MailComponent', () => {
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted mail account')
})
+ it('should support process mail account, show error if needed', () => {
+ completeSetup()
+ const processSpy = jest.spyOn(mailAccountService, 'processAccount')
+ const toastErrorSpy = jest.spyOn(toastService, 'showError')
+ const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
+ component.processAccount(mailAccounts[0] as MailAccount)
+ expect(processSpy).toHaveBeenCalled()
+ processSpy.mockReturnValueOnce(
+ throwError(() => new Error('error processing mail account'))
+ )
+ component.processAccount(mailAccounts[0] as MailAccount)
+ expect(toastErrorSpy).toHaveBeenCalled()
+ processSpy.mockReturnValueOnce(of(true))
+ component.processAccount(mailAccounts[0] as MailAccount)
+ expect(toastInfoSpy).toHaveBeenCalledWith('Processing mail account')
+ })
+
it('should support edit / create mail rule, show error if needed', () => {
completeSetup()
let modal: NgbModalRef
diff --git a/src-ui/src/app/components/manage/mail/mail.component.ts b/src-ui/src/app/components/manage/mail/mail.component.ts
index dce23b4b6..c15ef28af 100644
--- a/src-ui/src/app/components/manage/mail/mail.component.ts
+++ b/src-ui/src/app/components/manage/mail/mail.component.ts
@@ -202,6 +202,17 @@ export class MailComponent
})
}
+ processAccount(account: MailAccount) {
+ this.mailAccountService.processAccount(account).subscribe({
+ next: () => {
+ this.toastService.showInfo($localize`Processing mail account`)
+ },
+ error: (e) => {
+ this.toastService.showError($localize`Error processing mail account`, e)
+ },
+ })
+ }
+
editMailRule(rule: MailRule = null, forceCreate = false) {
const modal = this.modalService.open(MailRuleEditDialogComponent, {
backdrop: 'static',
diff --git a/src-ui/src/app/services/rest/mail-account.service.spec.ts b/src-ui/src/app/services/rest/mail-account.service.spec.ts
index c9d1da7d1..ef69b979e 100644
--- a/src-ui/src/app/services/rest/mail-account.service.spec.ts
+++ b/src-ui/src/app/services/rest/mail-account.service.spec.ts
@@ -68,6 +68,14 @@ describe(`Additional service tests for MailAccountService`, () => {
expect(service.allAccounts).toEqual(mail_accounts)
})
+ it('should support processAccount', () => {
+ subscription = service.processAccount(mail_accounts[0]).subscribe()
+ const req = httpTestingController.expectOne(
+ `${environment.apiBaseUrl}${endpoint}/${mail_accounts[0].id}/process/`
+ )
+ expect(req.request.method).toEqual('POST')
+ })
+
beforeEach(() => {
// Dont need to setup again
diff --git a/src-ui/src/app/services/rest/mail-account.service.ts b/src-ui/src/app/services/rest/mail-account.service.ts
index c5c2c79e0..e946b1399 100644
--- a/src-ui/src/app/services/rest/mail-account.service.ts
+++ b/src-ui/src/app/services/rest/mail-account.service.ts
@@ -47,4 +47,8 @@ export class MailAccountService extends AbstractPaperlessService