From ef8df96e651a2348f948771d0dcacd584382b1c0 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 17 Aug 2026 10:14:31 +0200 Subject: [PATCH] feat(application): add IOAuth2TokenService and IPop3EmailService interfaces --- .../Common/Interfaces/IOAuth2TokenService.cs | 18 +++++++++++++ .../Common/Interfaces/IPop3EmailService.cs | 25 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/core/DigitalData.MessagingService.Application/Common/Interfaces/IOAuth2TokenService.cs create mode 100644 src/core/DigitalData.MessagingService.Application/Common/Interfaces/IPop3EmailService.cs diff --git a/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IOAuth2TokenService.cs b/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IOAuth2TokenService.cs new file mode 100644 index 0000000..3a4ac71 --- /dev/null +++ b/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IOAuth2TokenService.cs @@ -0,0 +1,18 @@ +#if NET +using DigitalData.MessagingService.Domain.Entities; + +namespace DigitalData.MessagingService.Application.Common.Interfaces; + +/// +/// Acquires and caches OAuth2 access tokens for email protocols (IMAP, POP3, SMTP). +/// Uses the client credentials flow (application-level auth — no user interaction required). +/// +public interface IOAuth2TokenService +{ + /// + /// Returns a valid access token for the given email account. + /// Tokens are cached and refreshed automatically before expiry. + /// + Task GetAccessTokenAsync(EmailAccount account, CancellationToken cancellationToken = default); +} +#endif diff --git a/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IPop3EmailService.cs b/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IPop3EmailService.cs new file mode 100644 index 0000000..aaf529d --- /dev/null +++ b/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IPop3EmailService.cs @@ -0,0 +1,25 @@ +#if NET +using DigitalData.MessagingService.Application.Common.Dto; +using DigitalData.MessagingService.Domain.Entities; + +namespace DigitalData.MessagingService.Application.Common.Interfaces; + +/// +/// Service interface for reading emails via POP3. +/// +public interface IPop3EmailService +{ + /// + /// Fetches new messages from the POP3 server and persists them locally. + /// Because POP3 has no folder concept, all messages are stored under the folder name "INBOX". + /// + Task SyncEmailsAsync( + EmailAccount account, + CancellationToken cancellationToken = default); + + /// + /// Gets the last POP3 sync date for the specified account. + /// + DateTime? GetLastPop3SyncDate(int accountId); +} +#endif