Revert "File scoped namespaces"

This reverts commit d31d8f574e.
This commit is contained in:
Burak Kaan Köse
2025-02-16 11:43:30 +01:00
parent d31d8f574e
commit cf9869b71e
617 changed files with 32097 additions and 31478 deletions

View File

@@ -5,28 +5,29 @@ using Google.Apis.Http;
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.Http;
internal class GmailClientMessageHandler : ConfigurableMessageHandler
namespace Wino.Core.Http
{
private readonly IGmailAuthenticator _gmailAuthenticator;
private readonly MailAccount _mailAccount;
public GmailClientMessageHandler(IGmailAuthenticator gmailAuthenticator, MailAccount mailAccount) : base(new HttpClientHandler())
internal class GmailClientMessageHandler : ConfigurableMessageHandler
{
_gmailAuthenticator = gmailAuthenticator;
_mailAccount = mailAccount;
}
private readonly IGmailAuthenticator _gmailAuthenticator;
private readonly 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.
public GmailClientMessageHandler(IGmailAuthenticator gmailAuthenticator, MailAccount mailAccount) : base(new HttpClientHandler())
{
_gmailAuthenticator = gmailAuthenticator;
_mailAccount = mailAccount;
}
var tokenInformation = await _gmailAuthenticator.GetTokenInformationAsync(_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.
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenInformation.AccessToken);
var tokenInformation = await _gmailAuthenticator.GetTokenInformationAsync(_mailAccount);
return await base.SendAsync(request, cancellationToken);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenInformation.AccessToken);
return await base.SendAsync(request, cancellationToken);
}
}
}

View File

@@ -2,17 +2,18 @@
using System.Threading;
using System.Threading.Tasks;
namespace Wino.Core.Http;
/// <summary>
/// Adds additional Prefer header for immutable id support in the Graph service client.
/// </summary>
public class MicrosoftImmutableIdHandler : DelegatingHandler
namespace Wino.Core.Http
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
/// <summary>
/// Adds additional Prefer header for immutable id support in the Graph service client.
/// </summary>
public class MicrosoftImmutableIdHandler : DelegatingHandler
{
request.Headers.TryAddWithoutValidation("Prefer", "IdType=\"ImmutableId\"");
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.TryAddWithoutValidation("Prefer", "IdType=\"ImmutableId\"");
return base.SendAsync(request, cancellationToken);
return base.SendAsync(request, cancellationToken);
}
}
}

View File

@@ -6,27 +6,28 @@ using Microsoft.Kiota.Abstractions.Authentication;
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.Http;
public class MicrosoftTokenProvider : IAccessTokenProvider
namespace Wino.Core.Http
{
private readonly MailAccount _account;
private readonly IAuthenticator _authenticator;
public MicrosoftTokenProvider(MailAccount account, IAuthenticator authenticator)
public class MicrosoftTokenProvider : IAccessTokenProvider
{
_account = account;
_authenticator = authenticator;
}
private readonly MailAccount _account;
private readonly IAuthenticator _authenticator;
public AllowedHostsValidator AllowedHostsValidator { get; }
public MicrosoftTokenProvider(MailAccount account, IAuthenticator authenticator)
{
_account = account;
_authenticator = authenticator;
}
public async Task<string> GetAuthorizationTokenAsync(Uri uri,
Dictionary<string, object> additionalAuthenticationContext = null,
CancellationToken cancellationToken = default)
{
var tokenInfo = await _authenticator.GetTokenInformationAsync(_account);
public AllowedHostsValidator AllowedHostsValidator { get; }
return tokenInfo.AccessToken;
public async Task<string> GetAuthorizationTokenAsync(Uri uri,
Dictionary<string, object> additionalAuthenticationContext = null,
CancellationToken cancellationToken = default)
{
var tokenInfo = await _authenticator.GetTokenInformationAsync(_account);
return tokenInfo.AccessToken;
}
}
}