Bug fixes

This commit is contained in:
Denis Volkov 2022-10-12 16:08:52 -07:00
parent ee856ef04a
commit 74feb0d7a3
2 changed files with 52 additions and 30 deletions

View File

@ -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;
}

View File

@ -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" })
<input type="text" class="prayer-item-edit-name" />
@Html.Label("Email", new { @class = "control-label" })
@Html.Label("Email *", new { @class = "control-label" })
<input type="text" class="prayer-item-edit-email" />
@Html.Label("Phone", new { @class = "control-label" })
<input type="text" class="prayer-item-edit-phone" />
@if (Model.IsAffiliateSmsCapable)
{
@Html.Label("Notification preference", new { @class = "control-label" })
<select class="prayer-item-edit-contactpreference">
<option value="email">Email me when someone prays</option>
@Html.Label("Notification preference", new { @class = "control-label" })
<select class="prayer-item-edit-contactpreference">
<option value="email">Email me when someone prays</option>
@if (Model.IsAffiliateSmsCapable)
{
<option value="phone">Text me when someone prays</option>
<option value="any">Email and text me when someone prays</option>
</select>
}
}
<option value="none">Do not notify me when someone prays</option>
</select>
@*}*@
@ -187,7 +188,7 @@ else if (Model.ShowPraiseListInstructions)
@*@Html.Label("Title", new { @class = "control-label" }) <span class="prayer-item-edit-summary-maxlength-feedback maxlength-feedback"></span>
<input type="text" class="prayer-item-edit-summary" spellcheck="true" />*@
@Html.Label("Prayer Request", new { @class = "control-label" })
@Html.Label("Prayer Request *", new { @class = "control-label" })
<textarea class="prayer-item-edit-content" rows="4" spellcheck="true"></textarea>
<div class="checkbox">
@ -210,31 +211,31 @@ else if (Model.ShowPraiseListInstructions)
}
@*<div class="checkbox">
<label>
<input type="checkbox" class="prayer-item-edit-notification"> Let me know when someone prays for my request via e-mail.
</label>
</div>*@
<label>
<input type="checkbox" class="prayer-item-edit-notification"> Let me know when someone prays for my request via e-mail.
</label>
</div>*@
@*if (Model.IsAffiliateSmsCapable && Model.IsUserSmsCapable)
{
<div class="checkbox">
<label>
<input type="checkbox" class="prayer-item-edit-notification-sms"> Let me know when someone prays for my request via text message.
</label>
</div>
}
else if (Model.IsAffiliateSmsCapable)
{
<div>
<a class="btn" href="@Url.Action( "Index", "Manage", routeValues: new { affiliatekey = (ViewBag.AffiliateKey ?? Amen.Controllers.ControllerHelper.DefaultAffiliateKey) })" title="Manage">Add Phone Number</a> to enable text notifications
</div>
}*@
{
<div class="checkbox">
<label>
<input type="checkbox" class="prayer-item-edit-notification-sms"> Let me know when someone prays for my request via text message.
</label>
</div>
}
else if (Model.IsAffiliateSmsCapable)
{
<div>
<a class="btn" href="@Url.Action( "Index", "Manage", routeValues: new { affiliatekey = (ViewBag.AffiliateKey ?? Amen.Controllers.ControllerHelper.DefaultAffiliateKey) })" title="Manage">Add Phone Number</a> to enable text notifications
</div>
}*@
}
else
{
@*<div>
<a class="btn" href="@Url.Action("Login", "Account", routeValues: new { affiliatekey = (ViewBag.AffiliateKey ?? Amen.Controllers.ControllerHelper.DefaultAffiliateKey) })">Log In</a> to enable notifications
</div>*@
<a class="btn" href="@Url.Action("Login", "Account", routeValues: new { affiliatekey = (ViewBag.AffiliateKey ?? Amen.Controllers.ControllerHelper.DefaultAffiliateKey) })">Log In</a> to enable notifications
</div>*@
}
}
@ -244,12 +245,14 @@ else if (Model.ShowPraiseListInstructions)
{
<div class="prayer-item-edit-instructions">
@{WriteLiteral(Model.InstructionsAddPrayer);}
<div style="padding-top:10px;"><strong>* Required fields</strong></div>
</div>
}
else if (Model.ShowAddPraiseInstructions)
{
<div class="prayer-item-edit-instructions">
@{WriteLiteral(Model.InstructionsAddPraise);}
<div style="padding-top:10px;"><strong>* Required fields</strong></div>
</div>
}