file scoped namespaces (#565)

This commit is contained in:
Aleh Khantsevich
2025-02-16 11:54:23 +01:00
committed by GitHub
parent cf9869b71e
commit 3ddc1a6229
617 changed files with 32107 additions and 32721 deletions

View File

@@ -5,29 +5,28 @@ using Google.Apis.Http;
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.Http
namespace Wino.Core.Http;
internal class GmailClientMessageHandler : ConfigurableMessageHandler
{
internal class GmailClientMessageHandler : ConfigurableMessageHandler
private readonly IGmailAuthenticator _gmailAuthenticator;
private readonly MailAccount _mailAccount;
public GmailClientMessageHandler(IGmailAuthenticator gmailAuthenticator, MailAccount mailAccount) : base(new HttpClientHandler())
{
private readonly IGmailAuthenticator _gmailAuthenticator;
private readonly MailAccount _mailAccount;
_gmailAuthenticator = gmailAuthenticator;
_mailAccount = mailAccount;
}
public GmailClientMessageHandler(IGmailAuthenticator gmailAuthenticator, MailAccount mailAccount) : base(new HttpClientHandler())
{
_gmailAuthenticator = gmailAuthenticator;
_mailAccount = mailAccount;
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// This call here will automatically trigger Google Auth's interactive login if the token is not found.
// or refresh the token based on the FileDataStore.
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// This call here will automatically trigger Google Auth's interactive login if the token is not found.
// or refresh the token based on the FileDataStore.
var tokenInformation = await _gmailAuthenticator.GetTokenInformationAsync(_mailAccount);
var tokenInformation = await _gmailAuthenticator.GetTokenInformationAsync(_mailAccount);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenInformation.AccessToken);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenInformation.AccessToken);
return await base.SendAsync(request, cancellationToken);
}
return await base.SendAsync(request, cancellationToken);
}
}