feat: enforce tenant content moderation
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user