diff --git a/src/formulate.app/Forms/Handlers/Email/EmailConfiguration.cs b/src/formulate.app/Forms/Handlers/Email/EmailConfiguration.cs index 427618d1..7b6ee491 100644 --- a/src/formulate.app/Forms/Handlers/Email/EmailConfiguration.cs +++ b/src/formulate.app/Forms/Handlers/Email/EmailConfiguration.cs @@ -1,7 +1,12 @@ namespace formulate.app.Forms.Handlers.Email { + + // Namespaces. + using formulate.core.Extensions; + using Newtonsoft.Json; using System; using System.Collections.Generic; + using System.Linq; /// /// Configuration used by . @@ -16,12 +21,32 @@ public class EmailConfiguration : IEmailSenderRecipientConfiguration /// /// Gets or sets the recipients of the email. /// - public IEnumerable Recipients { get; set; } + [JsonProperty("recipients")] + public IEnumerable RecipientsData { get; set; } + + /// + /// Gets the recipients of the email. + /// + /// + /// This is a duplicate property because this version implements the interface, + /// which requires a slightly different data type. + /// + public IEnumerable Recipients => RecipientsData.MakeSafe().Select(x => x.Email).ToArray(); /// /// Gets or sets the fields containing the recipients of the email. /// - public IEnumerable RecipientFields { get; set; } + [JsonProperty("recipientFields")] + public IEnumerable RecipientFieldsData { get; set; } + + /// + /// Gets the fields containing the recipients of the email. + /// + /// + /// This is a duplicate property because this version implements the interface, + /// which requires a slightly different data type. + /// + public IEnumerable RecipientFields => RecipientFieldsData.MakeSafe().Select(x => x.Id).ToArray(); /// /// Gets or sets the type of delivery for the recipients (e.g., to, cc, bcc). @@ -31,7 +56,17 @@ public class EmailConfiguration : IEmailSenderRecipientConfiguration /// /// Gets or sets the fields to include. /// - public IEnumerable FieldsToInclude { get; set; } + [JsonProperty("fieldsToInclude")] + public IEnumerable FieldsToIncludeData { get; set; } + + /// + /// Gets the fields to include. + /// + /// + /// This is a convenience property that extracts the important data + /// from the other version of this property. + /// + public IEnumerable FieldsToInclude => FieldsToIncludeData.MakeSafe().Select(x => x.Id).ToArray(); /// /// Gets or sets the message. diff --git a/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs b/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs index f2dc7288..e7bf4f0c 100644 --- a/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs +++ b/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs @@ -294,7 +294,6 @@ protected MailMessage PrepareEmailMessage( // Any allowed recipients (if not, abort early)? var rawRecipients = config.Recipients - .Select(x => x.Email) .Concat(fieldEmails) .Concat(extraEmails); var allowedRecipients = FilterEmails(rawRecipients); diff --git a/src/formulate.app/Forms/Handlers/Email/IEmailSenderRecipientConfiguration.cs b/src/formulate.app/Forms/Handlers/Email/IEmailSenderRecipientConfiguration.cs index d6e628e1..b47bde8d 100644 --- a/src/formulate.app/Forms/Handlers/Email/IEmailSenderRecipientConfiguration.cs +++ b/src/formulate.app/Forms/Handlers/Email/IEmailSenderRecipientConfiguration.cs @@ -21,7 +21,7 @@ public interface IEmailSenderRecipientConfiguration /// /// Gets the recipients of the email. /// - IEnumerable Recipients { get; } + IEnumerable Recipients { get; } /// /// Gets the fields containing the recipients of the email. diff --git a/src/formulate.app/Forms/Handlers/Email/RecipientField.cs b/src/formulate.app/Forms/Handlers/Email/RecipientField.cs new file mode 100644 index 00000000..4daa6aae --- /dev/null +++ b/src/formulate.app/Forms/Handlers/Email/RecipientField.cs @@ -0,0 +1,24 @@ +namespace formulate.app.Forms.Handlers.Email +{ + + // Namespaces. + using System; + + /// + /// An object that contains an ID that is a GUID. + /// + public class GuidId + { + + #region Properties + + /// + /// The GUID ID. + /// + public Guid Id { get; set; } + + #endregion + + } + +} \ No newline at end of file diff --git a/src/formulate.app/formulate.app.csproj b/src/formulate.app/formulate.app.csproj index ff9f1572..27d10d08 100644 --- a/src/formulate.app/formulate.app.csproj +++ b/src/formulate.app/formulate.app.csproj @@ -350,6 +350,7 @@ +