Skip to content

Commit

Permalink
Fixed mistake in postgres-secret.yaml where stringData was used inste…
Browse files Browse the repository at this point in the history
…ad of data. Moved sender email from mailhog-secret.yaml to mailhog-config.yaml. Removed logging of sender email in EmailMessageRelay.cs.

Co-authored-by: Adrian Essig <[email protected]>
  • Loading branch information
Smightym8 and Essiga committed Jul 10, 2024
1 parent 4d47481 commit cc25df1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 25 deletions.
17 changes: 3 additions & 14 deletions ClubService.Infrastructure/Mail/EmailMessageRelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class EmailMessageRelay : BackgroundService
{
private readonly ILoggerService<EmailMessageRelay> _loggerService;
private readonly int _pollingInterval;
private readonly string _senderEmailAddress;
private readonly MailAddress _senderEmailAddress;
private readonly IServiceProvider _serviceProvider;
private readonly SmtpClient _smtpClient;

Expand All @@ -24,7 +24,7 @@ public EmailMessageRelay(
_serviceProvider = serviceProvider;
_loggerService = loggerService;
_pollingInterval = smtpConfiguration.Value.PollingInterval;
_senderEmailAddress = smtpConfiguration.Value.SenderEmailAddress;
_senderEmailAddress = new MailAddress(smtpConfiguration.Value.SenderEmailAddress);
_smtpClient = new SmtpClient(smtpConfiguration.Value.Host, smtpConfiguration.Value.Port);
_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
}
Expand All @@ -42,17 +42,6 @@ private async Task SendEmails()
await transactionManager.TransactionScope(async () =>
{
MailAddress recipientEmailAddress;
MailAddress senderMailAddress;
try
{
senderMailAddress = new MailAddress(_senderEmailAddress);
}
catch (FormatException)
{
_loggerService.LogInvalidEMailAddress(_senderEmailAddress);
throw;
}

try
{
recipientEmailAddress = new MailAddress(emailMessage.RecipientEMailAddress);
Expand All @@ -63,7 +52,7 @@ await transactionManager.TransactionScope(async () =>
throw;
}

var mailMessage = new MailMessage(senderMailAddress, recipientEmailAddress)
var mailMessage = new MailMessage(_senderEmailAddress, recipientEmailAddress)
{
Subject = emailMessage.Subject,
Body = emailMessage.Body
Expand Down
3 changes: 2 additions & 1 deletion deployment/configs/mailhog-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ metadata:
name: club-service-mailhog-config
data:
mailhog-host: "club-service-mailhog-service"
mailhog-smtp-port: "1025"
mailhog-smtp-port: "1025"
smtp-sender-email-address: "[email protected]"
4 changes: 2 additions & 2 deletions deployment/deployments/club-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ spec:
key: mailhog-smtp-port
- name: SMTP_SENDER_EMAIL_ADDRESS
valueFrom:
secretKeyRef:
name: club-service-mailhog-secret
configMapKeyRef:
name: club-service-mailhog-config
key: smtp-sender-email-address
7 changes: 0 additions & 7 deletions deployment/secrets/mailhog-secret.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion deployment/secrets/postgres-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ kind: Secret
metadata:
name: club-service-postgres-secret
type: Opaque
stringData:
data:
postgres-user: dXNlcgo=
postgres-password: cGFzc3dvcmQK

0 comments on commit cc25df1

Please sign in to comment.