滥用插件自动执行滥用检测,以防止垃圾信息或其他滥用进入平台。单个滥用检测器处理适用于其滥用检测逻辑的事件,并在检测到滥用时通知滥用服务。
IAbuseCheckingContentType 接口定义了支持滥用服务所需的方法。实现此服务的内容类型可以标记为滥用,如果添加了足够的标记,则可以将其隐藏,并使用滥用 UI 进行审核。
帮助促使平台会员更诚信。那些对可疑内容负责的人会通过电子邮件发送他们,陈述他们的内容被视为滥用,并可以对电子邮件的质疑提出申诉。
在此示例中,我们基于应用程序/内容示例进行构建。请务必注意,可以在同一 IContentType 类中实现一个或多个核心服务。
我们采用了 IContentType 实现,并进一步扩展了 IAbuseCheckingContentType 接口。
using System;
using System.Collections.Generic;
using Limyee.Extensibility.Content.Version1;
using Limyee.Extensions.Lists.Data;
using IContent = Limyee.Extensibility.Content.Version1.IContent;
namespace Limyee.Extensions.Lists
{
public interface ILinkItemContentType : IContentType, IAbuseCheckingContentType
{
IContentStateChanges _contentState = null;
#region IPlugin
//...
#endregion
#region IContentType
//...
#endregion
#region IAbuseCheckingContentType
//...
#endregion
}
}
当一段内容首次被标记为滥用时,将调用 ContentSuspectedAbusive 方法。这里的演示是暂时禁用内容。因此,我们将 LinkItem 的 IsEnabled 属性设置为 false;
public void ContentSuspectedAbusive(Guid abuseId, Guid contentId)
{
var content = LinksData.GetLink(contentId);
if (content == null) return;
content.IsEnabled = false;
}
在通知用户其内容被标记后,他们可以对该操作提出申诉。如果审核员接受废除,他们可以批准内容并将其恢复到平台中。示例是执行 ContentFoundNotAbusive 方法并且 IsEnabled 标志设置回 true;
public void ContentFoundNotAbusive(Guid abuseId, Guid contentId)
{
var content = LinksData.GetLink(contentId);
if (content == null) return;
content.IsEnabled = true;
}
另一方面,如果内容被认为不适合平台。然后调用 ContentConfirmedAbusive 方法,删除内容。
public void ContentConfirmedAbusive(Guid abuseId, Guid contentId)
{
LinksData.DeleteLink(contentId);
}
在大多数情况下,当内容被标记为滥用时,您希望修剪滥用内容的结果集。为了使平台能够检索禁用的内容,需要 GetHiddenContent 方法。在这里是返回禁用内容。
public IContent GetHiddenContent(Guid contentId)
{
return LinksData.GetLink(contentId);
}
下面是完整示例。
using System;
using System.Collections.Generic;
using Limyee.Extensibility.Content.Version1;
using Limyee.Extensions.Lists.Data;
using IContent = Limyee.Extensibility.Content.Version1.IContent;
namespace Samples.Links
{
public class LinkItemContentType : IAbuseCheckingContentType
{
IContentStateChanges _contentState = null;
#region IPlugin Members
public string Description
{
get { return "Items in a Links collection"; }
}
public void Initialize()
{
}
public string Name
{
get { return "Link Items"; }
}
#endregion
#region IContentType Members
public Guid[] ApplicationTypes
{
get { return new Guid[] { ContentTypes.LinksApplicationId }; }
}
public void AttachChangeEvents(IContentStateChanges stateChanges)
{
_contentState = stateChanges;
}
public Guid ContentTypeId
{
get { return ContentTypes.LinksItemId; }
}
public string ContentTypeName
{
get { return "Links Item"; }
}
public IContent Get(Guid contentId)
{
return LinksData.GetLink(contentId);
}
#endregion
#region IAbuseCheckingContentType
public List<int> GetReviewBoardUsers(Guid contentId)
{
//Deprecated: The service now uses the group or site Manage Abuse permission
return null;
}
public bool CanUserReviewAppeals(Guid contentId, int userId)
{
//Deprecated: The service now uses the group or site Manage Abuse permission
return false;
}
public void ContentSuspectedAbusive(Guid abuseId, Guid contentId)
{
var content = LinksData.GetLink(contentId);
if (content == null) return;
content.IsEnabled = false;
}
public void ContentFoundNotAbusive(Guid abuseId, Guid contentId)
{
var content = LinksData.GetLink(contentId);
if (content == null) return;
content.IsEnabled = true;
}
public void ContentConfirmedAbusive(Guid abuseId, Guid contentId)
{
LinksData.DeleteLink(contentId);
}
public IContent GetHiddenContent(Guid contentId)
{
return LinksData.GetLink(contentId);
}
#endregion
}
}