-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to use IEmailSender when contributors are deleted
- Loading branch information
Showing
9 changed files
with
67 additions
and
14 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
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,4 +1,5 @@ | ||
using Clean.Architecture.Core.ContributorAggregate.Events; | ||
using Clean.Architecture.Core.Interfaces; | ||
using MediatR; | ||
using Microsoft.Extensions.Logging; | ||
|
||
|
@@ -7,13 +8,16 @@ namespace Clean.Architecture.Core.ContributorAggregate.Handlers; | |
/// <summary> | ||
/// NOTE: Internal because ContributorDeleted is also marked as internal. | ||
/// </summary> | ||
internal class ContributorDeletedHandler(ILogger<ContributorDeletedHandler> _logger) : INotificationHandler<ContributorDeletedEvent> | ||
internal class ContributorDeletedHandler(ILogger<ContributorDeletedHandler> logger, | ||
IEmailSender emailSender) : INotificationHandler<ContributorDeletedEvent> | ||
{ | ||
public async Task Handle(ContributorDeletedEvent domainEvent, CancellationToken cancellationToken) | ||
{ | ||
_logger.LogInformation("Handling Contributed Deleted event for {contributorId}", domainEvent.ContributorId); | ||
logger.LogInformation("Handling Contributed Deleted event for {contributorId}", domainEvent.ContributorId); | ||
|
||
// TODO: do meaningful work here | ||
await Task.Delay(1); | ||
await emailSender.SendEmailAsync("[email protected]", | ||
"[email protected]", | ||
"Contributor Deleted", | ||
$"Contributor with id {domainEvent.ContributorId} was deleted."); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/Clean.Architecture.Infrastructure/Email/MailserverConfiguration.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,7 @@ | ||
namespace Clean.Architecture.Infrastructure.Email; | ||
|
||
public class MailserverConfiguration() | ||
{ | ||
public string Hostname { get; set; } = "localhost"; | ||
public int Port { get; set; } = 25; | ||
} |
22 changes: 17 additions & 5 deletions
22
src/Clean.Architecture.Infrastructure/Email/MimeKitEmailSender.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
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
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 |
---|---|---|
|
@@ -28,5 +28,9 @@ | |
// } | ||
//} | ||
] | ||
}, | ||
"Mailserver": { | ||
"Server": "localhost", | ||
"Port": 25 | ||
} | ||
} |