-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/inbound_parse_webhook' into develop
# Conflicts: # Source/StrongGrid/project.json
- Loading branch information
Showing
9 changed files
with
373 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace StrongGrid.Model.Webhooks | ||
{ | ||
/// <summary> | ||
/// The parsed information about an email sent by SendGrid via a webhook | ||
/// </summary> | ||
public class InboundEmail | ||
{ | ||
/// <summary> | ||
/// Gets or sets the headers of the email. | ||
/// </summary> | ||
/// <value> | ||
/// The headers. | ||
/// </value> | ||
public KeyValuePair<string, string>[] Headers { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a string containing the verification results of any DKIM and domain keys signatures in the message. | ||
/// </summary> | ||
/// <value> | ||
/// The dkim. | ||
/// </value> | ||
public string Dkim { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the email recipient field, as taken from the message headers. | ||
/// </summary> | ||
/// <value> | ||
/// To. | ||
/// </value> | ||
public MailAddress To { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the HTML body of email.If not set, email did not have an HTML body. | ||
/// </summary> | ||
/// <value> | ||
/// The HTML. | ||
/// </value> | ||
public string Html { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets from the email sender, as taken from the message headers | ||
/// </summary> | ||
/// <value> | ||
/// From. | ||
/// </value> | ||
public MailAddress From { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the sender's ip address. | ||
/// </summary> | ||
/// <value> | ||
/// The sender ip. | ||
/// </value> | ||
public string SenderIp { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the Spam Assassin's spam report. | ||
/// </summary> | ||
/// <value> | ||
/// The spam report. | ||
/// </value> | ||
public string SpamReport { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the SMTP envelope. | ||
/// This will have two variables: | ||
/// - to, which is a single-element array containing the address that we received the email to, | ||
/// - from, which is the return path for the message. | ||
/// </summary> | ||
/// <value> | ||
/// The envelope. | ||
/// </value> | ||
public InboundEmailEnvelope Envelope { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the email subject. | ||
/// </summary> | ||
/// <value> | ||
/// The subject. | ||
/// </value> | ||
public string Subject { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the Spam Assassin’s rating for whether or not this is spam. | ||
/// </summary> | ||
/// <value> | ||
/// The spam score. | ||
/// </value> | ||
public string SpamScore { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the attachment. | ||
/// </summary> | ||
/// <value> | ||
/// The attachment. | ||
/// </value> | ||
public InboundEmailAttachment[] Attachments { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the character sets of the fields extracted from the message. | ||
/// </summary> | ||
/// <value> | ||
/// The charsets. | ||
/// </value> | ||
public KeyValuePair<string, Encoding>[] Charsets { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the results of the Sender Policy Framework verification of the message sender | ||
/// and receiving IP address. | ||
/// </summary> | ||
/// <value> | ||
/// The SPF. | ||
/// </value> | ||
public string Spf { get; set; } | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Source/StrongGrid/Model/Webhooks/InboundEmailAttachment.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,60 @@ | ||
using Newtonsoft.Json; | ||
using System.IO; | ||
|
||
namespace StrongGrid.Model.Webhooks | ||
{ | ||
public class InboundEmailAttachment | ||
{ | ||
|
||
/// <summary> | ||
/// Gets or sets the identifier. | ||
/// </summary> | ||
/// <value> | ||
/// The identifier. | ||
/// </value> | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the content-type. Defaults to text/plain if unspecified. | ||
/// </summary> | ||
/// <value> | ||
/// The content-type. | ||
/// </value> | ||
public string ContentType { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the data. | ||
/// </summary> | ||
/// <value> | ||
/// The data. | ||
/// </value> | ||
public Stream Data { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the file name. | ||
/// </summary> | ||
/// <value> | ||
/// The name of the file. | ||
/// </value> | ||
[JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)] | ||
public string FileName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the name. | ||
/// </summary> | ||
/// <value> | ||
/// The name. | ||
/// </value> | ||
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the content identifier. | ||
/// </summary> | ||
/// <value> | ||
/// The content identifier. | ||
/// </value> | ||
[JsonProperty("content-id", NullValueHandling = NullValueHandling.Ignore)] | ||
public string ContentId { 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,31 @@ | ||
using Newtonsoft.Json; | ||
using StrongGrid.Utilities; | ||
using System; | ||
|
||
namespace StrongGrid.Model.Webhooks | ||
{ | ||
/// <summary> | ||
/// The SMTP envelope | ||
/// </summary> | ||
public class InboundEmailEnvelope | ||
{ | ||
/// <summary> | ||
/// Gets or sets to, which is a single-element array containing the address that we received the email to, | ||
/// </summary> | ||
/// <value> | ||
/// To. | ||
/// </value> | ||
[JsonProperty("to", NullValueHandling = NullValueHandling.Ignore)] | ||
public string[] To { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets from, which is the return path for the message. | ||
|
||
/// </summary> | ||
/// <value> | ||
/// From. | ||
/// </value> | ||
[JsonProperty("from", NullValueHandling = NullValueHandling.Ignore)] | ||
public string From { 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
Oops, something went wrong.