From 74feb0d7a34ddc61bf212121e06c4adb78e0fa28 Mon Sep 17 00:00:00 2001 From: Denis Volkov Date: Wed, 12 Oct 2022 16:08:52 -0700 Subject: [PATCH] Bug fixes --- Amen/Controllers/PrayerController.cs | 21 +++++++++- Amen/Views/Prayer/Index.cshtml | 61 +++++++++++++++------------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/Amen/Controllers/PrayerController.cs b/Amen/Controllers/PrayerController.cs index 43e23ad..f70d4a8 100644 --- a/Amen/Controllers/PrayerController.cs +++ b/Amen/Controllers/PrayerController.cs @@ -498,10 +498,11 @@ namespace Amen.Controllers ipAddress = (ipAddress ?? "").Trim(); var affiliate = controllerHelper.db.Affiliates.Include("BlacklistEmails").Include("BlacklistIPs").Include("AutoFlagItems").FirstOrDefault(i => i.Key == affiliatekey && i.IsActive); + var defaultAffiliate = controllerHelper.db.Affiliates.Include("BlacklistEmails").Include("BlacklistIPs").Include("AutoFlagItems").FirstOrDefault(i => i.Key.Equals(ControllerHelper.DefaultAffiliateKey, StringComparison.InvariantCultureIgnoreCase)); if (affiliate == null) { - affiliate = controllerHelper.db.Affiliates.Include("BlacklistEmails").Include("BlacklistIPs").Include("AutoFlagItems").FirstOrDefault(i => i.Key.Equals(ControllerHelper.DefaultAffiliateKey, StringComparison.InvariantCultureIgnoreCase)); + affiliate = defaultAffiliate; } //ensure not a blacklist email address @@ -533,6 +534,24 @@ namespace Amen.Controllers return false; } } + + // check also against the master list of the default affiliate + if (defaultAffiliate.AutoFlagItems.Count > 0) + { + subject = subject.StripPunctuation().ToLower(); + content = content.StripPunctuation().ToLower(); + + var flagWords = @"\b(" + string.Join("|", defaultAffiliate.AutoFlagItems.Select(i => i.Text.ToLower()).ToArray()) + @")\b"; + var subjectMatch = Regex.IsMatch(subject, flagWords); + var contentMatch = Regex.IsMatch(content, flagWords); + + if (contentMatch || subjectMatch) + { + message = "Title or Content contains inappropriate word or phrase."; + return false; + } + } + return true; } diff --git a/Amen/Views/Prayer/Index.cshtml b/Amen/Views/Prayer/Index.cshtml index 93afefe..b9a3242 100644 --- a/Amen/Views/Prayer/Index.cshtml +++ b/Amen/Views/Prayer/Index.cshtml @@ -156,24 +156,25 @@ else if (Model.ShowPraiseListInstructions) else {*@ - @Html.Label("First Name", new { @class = "control-label" }) + @Html.Label("First Name *", new { @class = "control-label" }) - @Html.Label("Email", new { @class = "control-label" }) + @Html.Label("Email *", new { @class = "control-label" }) @Html.Label("Phone", new { @class = "control-label" }) - @if (Model.IsAffiliateSmsCapable) - { - @Html.Label("Notification preference", new { @class = "control-label" }) - + + @if (Model.IsAffiliateSmsCapable) + { - - } + } + + @*}*@ @@ -187,7 +188,7 @@ else if (Model.ShowPraiseListInstructions) @*@Html.Label("Title", new { @class = "control-label" }) *@ - @Html.Label("Prayer Request", new { @class = "control-label" }) + @Html.Label("Prayer Request *", new { @class = "control-label" })
@@ -210,31 +211,31 @@ else if (Model.ShowPraiseListInstructions) } @*
- -
*@ + +
*@ @*if (Model.IsAffiliateSmsCapable && Model.IsUserSmsCapable) - { -
- -
- } - else if (Model.IsAffiliateSmsCapable) - { -
- Add Phone Number to enable text notifications -
- }*@ + { +
+ +
+ } + else if (Model.IsAffiliateSmsCapable) + { +
+ Add Phone Number to enable text notifications +
+ }*@ } else { @*
- Log In to enable notifications -
*@ + Log In to enable notifications + *@ } } @@ -244,12 +245,14 @@ else if (Model.ShowPraiseListInstructions) {
@{WriteLiteral(Model.InstructionsAddPrayer);} +
* Required fields
} else if (Model.ShowAddPraiseInstructions) {
@{WriteLiteral(Model.InstructionsAddPraise);} +
* Required fields
}