-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The service can now receive bounce events.
- Loading branch information
nbitounis
committed
Jun 2, 2020
1 parent
4286420
commit c667739
Showing
10 changed files
with
160 additions
and
13 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
Projects/SesNotifications.App/Factories/DbSesBounceEventFactory.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,32 @@ | ||
using SesNotifications.App.Models; | ||
using System; | ||
using System.Linq; | ||
using SesBounceEvent = SesNotifications.DataAccess.Entities.SesBounceEvent; | ||
|
||
namespace SesNotifications.App.Factories | ||
{ | ||
public static class DbSesBounceEventFactory | ||
{ | ||
public static SesBounceEvent Create(this SesBounceEventModel bounce, long notificationId) | ||
{ | ||
return new SesBounceEvent | ||
{ | ||
Id = notificationId, | ||
NotificationId = notificationId, | ||
NotificationType = "Bounce", | ||
SentAt = Convert.ToDateTime(bounce.Mail.Timestamp), | ||
MessageId = bounce.Mail.MessageId, | ||
Source = bounce.Mail.Source, | ||
SourceArn = bounce.Mail.SourceArn, | ||
SourceIp = bounce.Mail.SourceIp, | ||
SendingAccountId = bounce.Mail.SendingAccountId, | ||
BounceType = bounce.Bounce.BounceType, | ||
BounceSubType = bounce.Bounce.BounceSubType, | ||
CreatedAt = Convert.ToDateTime(bounce.Bounce.Timestamp), | ||
FeedbackId = bounce.Bounce.FeedbackId, | ||
ReportingMta = bounce.Bounce.ReportingMta, | ||
BouncedRecipients = string.Join(',', bounce.Bounce.BouncedRecipients.Select(x => x.EmailAddress).ToArray()) | ||
}; | ||
} | ||
} | ||
} |
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,12 @@ | ||
namespace SesNotifications.App.Models | ||
{ | ||
public class SesBounceEvent | ||
{ | ||
public virtual string BounceType { get; set; } | ||
public virtual string BounceSubType { get; set; } | ||
public virtual SesBouncedRecipient[] BouncedRecipients { get; set; } | ||
public virtual string Timestamp { get; set; } | ||
public virtual string FeedbackId { get; set; } | ||
public virtual string ReportingMta { get; set; } | ||
} | ||
} |
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 SesNotifications.App.Models | ||
{ | ||
public class SesBounceEventModel : Ses | ||
{ | ||
public virtual SesMail Mail { get; set; } | ||
public virtual SesBounceEvent Bounce { get; set; } | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
Tests/SesNotifications.App.Tests/Factories/DbSesBounceEventFactoryTests.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,31 @@ | ||
using System; | ||
using System.Linq; | ||
using SesNotifications.App.Factories; | ||
using SesNotifications.App.Tests.Helpers; | ||
using Xunit; | ||
|
||
namespace SesNotifications.App.Tests.Factories | ||
{ | ||
public class DbSesBounceEventFactoryTests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var dt = DateTime.UtcNow; | ||
var bounce = TestHelpers.GetSesBounceEventModel(dt); | ||
|
||
var sesBounce = bounce.Create(1); | ||
|
||
Assert.Equal(sesBounce.BouncedRecipients, string.Join(',', bounce.Bounce.BouncedRecipients.Select(x => x.EmailAddress).ToArray())); | ||
Assert.Equal(sesBounce.BounceSubType, bounce.Bounce.BounceSubType); | ||
Assert.Equal(sesBounce.BounceType, bounce.Bounce.BounceType); | ||
Assert.Equal(sesBounce.CreatedAt.Iso8601(), dt.Iso8601()); | ||
Assert.Equal(sesBounce.FeedbackId, bounce.Bounce.FeedbackId); | ||
Assert.Equal(sesBounce.ReportingMta, bounce.Bounce.ReportingMta); | ||
Assert.Equal(sesBounce.SourceArn, bounce.Mail.SourceArn); | ||
Assert.Equal(sesBounce.NotificationType, bounce.NotificationType); | ||
Assert.Equal(1, sesBounce.NotificationId); | ||
Assert.Equal(sesBounce.MessageId, bounce.Mail.MessageId); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.