-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from belmirp/aws-ses-implementation
AWS SES implementation
- Loading branch information
Showing
34 changed files
with
1,405 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace UT4MasterServer.Common.Enums; | ||
|
||
public enum AccountStatus | ||
{ | ||
PendingActivation = 0, | ||
Active = 1, | ||
} |
14 changes: 14 additions & 0 deletions
14
UT4MasterServer.Common/Exceptions/AccountActivationException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace UT4MasterServer.Common.Exceptions; | ||
|
||
[Serializable] | ||
public sealed class AccountActivationException : Exception | ||
{ | ||
public AccountActivationException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public AccountActivationException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
UT4MasterServer.Common/Exceptions/AccountNotActiveException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace UT4MasterServer.Common.Exceptions; | ||
|
||
[Serializable] | ||
public sealed class AccountNotActiveException : Exception | ||
{ | ||
public AccountNotActiveException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public AccountNotActiveException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
UT4MasterServer.Common/Exceptions/AwsSesClientException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace UT4MasterServer.Common.Exceptions; | ||
|
||
[Serializable] | ||
public sealed class AwsSesClientException : Exception | ||
{ | ||
public AwsSesClientException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public AwsSesClientException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace UT4MasterServer.Common.Exceptions; | ||
|
||
[Serializable] | ||
public sealed class NotFoundException : Exception | ||
{ | ||
public NotFoundException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public NotFoundException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
UT4MasterServer.Common/Exceptions/RateLimitExceededException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace UT4MasterServer.Common.Exceptions; | ||
|
||
[Serializable] | ||
public sealed class RateLimitExceededException : Exception | ||
{ | ||
public RateLimitExceededException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public RateLimitExceededException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace UT4MasterServer.Models.DTO.Request; | ||
|
||
public sealed class SendEmailRequest | ||
{ | ||
public string From { get; set; } = string.Empty; | ||
public List<string> To { get; set; } = new(); | ||
public string Subject { get; set; } = string.Empty; | ||
public string Body { get; set; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace UT4MasterServer.Models.Settings; | ||
|
||
public sealed class AWSSettings | ||
{ | ||
public string AccessKey { get; set; } = string.Empty; | ||
public string SecretKey { get; set; } = string.Empty; | ||
public string RegionName { get; set; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 35 additions & 43 deletions
78
UT4MasterServer.Services/Hosted/ApplicationStartupService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,42 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using UT4MasterServer.Models.Settings; | ||
using UT4MasterServer.Services.Scoped; | ||
|
||
namespace UT4MasterServer.Services.Hosted | ||
namespace UT4MasterServer.Services.Hosted; | ||
|
||
public sealed class ApplicationStartupService : IHostedService | ||
{ | ||
public sealed class ApplicationStartupService : IHostedService | ||
private readonly ILogger<ApplicationStartupService> logger; | ||
private readonly IServiceProvider serviceProvider; | ||
|
||
public ApplicationStartupService(ILogger<ApplicationStartupService> logger, IServiceProvider serviceProvider) | ||
{ | ||
this.logger = logger; | ||
this.serviceProvider = serviceProvider; | ||
} | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
private readonly ILogger<ApplicationStartupService> logger; | ||
private readonly AccountService accountService; | ||
private readonly StatisticsService statisticsService; | ||
private readonly CloudStorageService cloudStorageService; | ||
private readonly ClientService clientService; | ||
private readonly RatingsService ratingsService; | ||
|
||
public ApplicationStartupService( | ||
ILogger<ApplicationStartupService> logger, | ||
ILogger<StatisticsService> statsLogger, | ||
IOptions<ApplicationSettings> settings, | ||
ILogger<CloudStorageService> cloudStorageLogger, | ||
ILogger<RatingsService> ratingsLogger) | ||
{ | ||
this.logger = logger; | ||
var db = new DatabaseContext(settings); | ||
accountService = new AccountService(db, settings); | ||
statisticsService = new StatisticsService(statsLogger, db); | ||
cloudStorageService = new CloudStorageService(db, cloudStorageLogger); | ||
clientService = new ClientService(db); | ||
ratingsService = new RatingsService(ratingsLogger, db); | ||
} | ||
|
||
public async Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
logger.LogInformation("Configuring MongoDB indexes."); | ||
await accountService.CreateIndexesAsync(); | ||
await statisticsService.CreateIndexesAsync(); | ||
await ratingsService.CreateIndexesAsync(); | ||
|
||
logger.LogInformation("Initializing MongoDB CloudStorage."); | ||
await cloudStorageService.EnsureSystemFilesExistAsync(); | ||
|
||
logger.LogInformation("Initializing MongoDB Clients."); | ||
await clientService.UpdateDefaultClientsAsync(); | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; | ||
using var scope = serviceProvider.CreateScope(); | ||
|
||
var accountService = scope.ServiceProvider.GetRequiredService<AccountService>(); | ||
var statisticsService = scope.ServiceProvider.GetRequiredService<StatisticsService>(); | ||
var ratingsService = scope.ServiceProvider.GetRequiredService<RatingsService>(); | ||
var cloudStorageService = scope.ServiceProvider.GetRequiredService<CloudStorageService>(); | ||
var clientService = scope.ServiceProvider.GetRequiredService<ClientService>(); | ||
|
||
logger.LogInformation("Configuring MongoDB indexes."); | ||
await accountService.CreateIndexesAsync(); | ||
await statisticsService.CreateIndexesAsync(); | ||
await ratingsService.CreateIndexesAsync(); | ||
|
||
logger.LogInformation("Initializing MongoDB CloudStorage."); | ||
await cloudStorageService.EnsureSystemFilesExistAsync(); | ||
|
||
logger.LogInformation("Initializing MongoDB Clients."); | ||
await clientService.UpdateDefaultClientsAsync(); | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; | ||
} |
Oops, something went wrong.