mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge pull request #5783 from mjy78/issue/20377
[Fixes #4206] Ensure comment tokens available to anti-spam module.
This commit is contained in:
@@ -144,7 +144,7 @@ namespace Orchard.AntiSpam.Controllers {
|
||||
if (spam != null) {
|
||||
spam.As<SpamFilterPart>().Status = SpamStatus.Spam;
|
||||
_spamService.ReportSpam(spam.As<SpamFilterPart>());
|
||||
Services.ContentManager.Publish(spam);
|
||||
Services.ContentManager.Unpublish(spam);
|
||||
}
|
||||
|
||||
return this.RedirectLocal(returnUrl, "~/");
|
||||
@@ -158,7 +158,7 @@ namespace Orchard.AntiSpam.Controllers {
|
||||
var spam = Services.ContentManager.Get(id, VersionOptions.Latest);
|
||||
if (spam != null) {
|
||||
spam.As<SpamFilterPart>().Status = SpamStatus.Ham;
|
||||
_spamService.ReportSpam(spam.As<SpamFilterPart>());
|
||||
_spamService.ReportHam(spam.As<SpamFilterPart>());
|
||||
Services.ContentManager.Publish(spam);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Orchard.AntiSpam.Models;
|
||||
using Orchard.AntiSpam.Services;
|
||||
using Orchard.AntiSpam.Settings;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
@@ -8,11 +7,9 @@ using Orchard.Localization;
|
||||
|
||||
namespace Orchard.AntiSpam.Drivers {
|
||||
public class SpamFilterPartDriver : ContentPartDriver<SpamFilterPart> {
|
||||
private readonly ISpamService _spamService;
|
||||
private const string TemplateName = "Parts/SpamFilter";
|
||||
|
||||
public SpamFilterPartDriver(IOrchardServices services, ISpamService spamService) {
|
||||
_spamService = spamService;
|
||||
public SpamFilterPartDriver(IOrchardServices services) {
|
||||
T = NullLocalizer.Instance;
|
||||
Services = services;
|
||||
}
|
||||
@@ -25,8 +22,6 @@ namespace Orchard.AntiSpam.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SpamFilterPart part, ContentManagement.IUpdateModel updater, dynamic shapeHelper) {
|
||||
part.Status = _spamService.CheckForSpam(part);
|
||||
|
||||
if (part.Settings.GetModel<SpamFilterPartSettings>().DeleteSpam) {
|
||||
updater.AddModelError("Spam", T("Spam detected."));
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
using Orchard.AntiSpam.Models;
|
||||
|
||||
using Orchard.AntiSpam.Services;
|
||||
using Orchard.AntiSpam.Settings;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Data;
|
||||
@@ -7,14 +7,22 @@ using Orchard.Data;
|
||||
namespace Orchard.AntiSpam.Handlers {
|
||||
public class SpamFilterPartHandler : ContentHandler {
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly ISpamService _spamService;
|
||||
|
||||
public SpamFilterPartHandler(
|
||||
IRepository<SpamFilterPartRecord> repository,
|
||||
ITransactionManager transactionManager
|
||||
ITransactionManager transactionManager,
|
||||
ISpamService spamService
|
||||
) {
|
||||
_transactionManager = transactionManager;
|
||||
_spamService = spamService;
|
||||
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
|
||||
OnCreating<SpamFilterPart>((context, part) => {
|
||||
part.Status = _spamService.CheckForSpam(part);
|
||||
});
|
||||
|
||||
OnPublishing<SpamFilterPart>((context, part) => {
|
||||
if (part.Status == SpamStatus.Spam) {
|
||||
if (part.Settings.GetModel<SpamFilterPartSettings>().DeleteSpam) {
|
||||
|
@@ -126,6 +126,7 @@ namespace Orchard.AntiSpam.Services {
|
||||
CommentAuthorEmail = _tokenizer.Replace(settings.CommentAuthorEmailPattern, data),
|
||||
CommentAuthorUrl = _tokenizer.Replace(settings.CommentAuthorUrlPattern, data),
|
||||
CommentContent = _tokenizer.Replace(settings.CommentContentPattern, data),
|
||||
CommentType = part.ContentItem.ContentType.ToLower()
|
||||
};
|
||||
|
||||
if(workContext.HttpContext != null) {
|
||||
|
Reference in New Issue
Block a user