63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package moderation
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/tinode/chat/server/store/types"
|
|
)
|
|
|
|
const (
|
|
SceneUserNickname = "user_nickname"
|
|
SceneUserSignature = "user_signature"
|
|
SceneGroupName = "group_name"
|
|
SceneGroupNickname = "group_nickname"
|
|
ScenePrivateMessage = "private_message"
|
|
SceneGroupMessage = "group_message"
|
|
SceneGroupAnnouncement = "group_announcement"
|
|
|
|
ActionAllow = "allow"
|
|
ActionBlock = "block"
|
|
ActionAuditOnly = "audit_only"
|
|
)
|
|
|
|
var (
|
|
ErrRejected = errors.New("content rejected")
|
|
ErrUnavailable = errors.New("content review unavailable")
|
|
)
|
|
|
|
type Request struct {
|
|
TenantID types.TenantID
|
|
TenantCode string
|
|
Scene string
|
|
ActorID types.Uid
|
|
Topic string
|
|
Text string
|
|
TraceID string
|
|
}
|
|
|
|
type ProviderResult struct {
|
|
ProviderRequestID string
|
|
RiskLevel string
|
|
RiskLabels []string
|
|
Summary string
|
|
Latency time.Duration
|
|
}
|
|
|
|
type Result struct {
|
|
RequestID string
|
|
Action string
|
|
RiskLevel string
|
|
RiskLabels []string
|
|
Provider string
|
|
ProviderRequestID string
|
|
Latency time.Duration
|
|
BlockMessage string
|
|
Err error
|
|
}
|
|
|
|
type Provider interface {
|
|
Review(context.Context, string, string, string) (*ProviderResult, error)
|
|
}
|