feat: sync durable moderation and appeals
This commit is contained in:
parent
e1a95c7318
commit
9f467f4be7
140 changed files with 13730 additions and 316 deletions
36
internal/app/moderation/service_test.go
Normal file
36
internal/app/moderation/service_test.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package moderation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
"telesrv/internal/store/memory"
|
||||
)
|
||||
|
||||
func TestAcceptReportReturnsDurableRetry(t *testing.T) {
|
||||
reports := memory.NewModerationReportStore()
|
||||
service := NewService(reports)
|
||||
draft := domain.ModerationReportDraft{
|
||||
ReporterUserID: 100, Source: domain.ModerationSourceMessagesSpam,
|
||||
Target: domain.Peer{Type: domain.PeerTypeUser, ID: 200},
|
||||
Reason: domain.ModerationReasonSpam, Option: "v1/spam",
|
||||
Items: []domain.ModerationReportItem{{
|
||||
Kind: domain.ModerationItemPeer,
|
||||
Peer: domain.Peer{Type: domain.PeerTypeUser, ID: 200},
|
||||
ItemID: 200, AuthorUserID: 200, EvidenceSchemaVersion: 1,
|
||||
Evidence: []byte(`{"snapshot":"peer"}`),
|
||||
}},
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
first, created, err := service.AcceptReport(context.Background(), draft)
|
||||
if err != nil || !created {
|
||||
t.Fatalf("first created=%v err=%v", created, err)
|
||||
}
|
||||
draft.CreatedAt = draft.CreatedAt.Add(time.Minute)
|
||||
retry, created, err := service.AcceptReport(context.Background(), draft)
|
||||
if err != nil || created || retry.ID != first.ID {
|
||||
t.Fatalf("retry=%+v created=%v err=%v", retry, created, err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue