File scoped namespaces

This commit is contained in:
Aleh Khantsevich
2025-02-16 11:35:43 +01:00
committed by GitHub
parent c1336428dc
commit d31d8f574e
617 changed files with 32118 additions and 32737 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);
}
}