37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
namespace DouyinApi.Model.Security
|
|||
|
|
{
|
|||
|
|
public class ContentSecurityResult
|
|||
|
|
{
|
|||
|
|
public bool IsSafe { get; init; }
|
|||
|
|
|
|||
|
|
public string RiskCode { get; init; } = string.Empty;
|
|||
|
|
|
|||
|
|
public string Message { get; init; } = string.Empty;
|
|||
|
|
|
|||
|
|
public IReadOnlyList<string> HitKeywords { get; init; } = Array.Empty<string>();
|
|||
|
|
|
|||
|
|
public static ContentSecurityResult Safe() => new ContentSecurityResult { IsSafe = true };
|
|||
|
|
|
|||
|
|
public static ContentSecurityResult Unsafe(string riskCode, string message) => Unsafe(riskCode, message, Array.Empty<string>());
|
|||
|
|
|
|||
|
|
public static ContentSecurityResult Unsafe(string riskCode, string message, IReadOnlyList<string> keywords)
|
|||
|
|
=> new ContentSecurityResult
|
|||
|
|
{
|
|||
|
|
IsSafe = false,
|
|||
|
|
RiskCode = riskCode,
|
|||
|
|
Message = message,
|
|||
|
|
HitKeywords = keywords ?? Array.Empty<string>()
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
public static ContentSecurityResult Failure(string message)
|
|||
|
|
=> new ContentSecurityResult
|
|||
|
|
{
|
|||
|
|
IsSafe = true,
|
|||
|
|
Message = message
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|