feat(verification): self-service request flow with mandatory review checklist

Gitea #10 Option B:
- new VerificationRequest model — owner submits a message via the pet
  edit page, moderator reviews against a fixed 4-item checklist
  (authenticity/impersonation risk, complete profile, good standing,
  established presence). All four met -> approved, Pet.isVerified flips
  on; any unmet -> auto-rejected with an itemized note of what's missing
- new admin queue /p/[secret]/verification (Moderator+ only, same gate
  as the audit log), status filter, review dialog enforces the checklist
- owner is notified automatically either way via a "PawFeed Team" DM —
  extracted the team-pet lookup/create logic (previously only inline in
  startTeamConversation) into src/lib/team-pet.ts, adding sendTeamMessage
  which reuses the normal Conversation/Message + MESSAGE notification
- review decisions log to ModerationLog with role+IP, same as every
  other Gitea #10 action this session
This commit is contained in:
admin committed 2026-08-12 10:03:59 +02:00
1 parent bc2dfa9a2d
commit a4c4568065
7 files changed
+606 -41

No files matched your search

+35 -1
View File
@@ -36,6 +36,38 @@ model Warning {
@@index([ownerId, createdAt(sort: Desc)])
}
enum VerificationRequestStatus {
PENDING
APPROVED
REJECTED
}
// Self-service verification request (Gitea #10). Reviewing is a fixed
// 4-item checklist, not free-form moderator judgment alone — all four must
// be true to approve; any false auto-rejects with an itemized note. The
// owner is notified via an automated "PawFeed Team" DM either way
// (src/lib/team-pet.ts) — see admin.reviewVerificationRequest.
model VerificationRequest {
id String @id @default(cuid())
pet Pet @relation(fields: [petId], references: [id], onDelete: Cascade)
petId String
message String @db.VarChar(1000) // requester's own justification
status VerificationRequestStatus @default(PENDING)
meetsAuthenticity Boolean? // real/notable pet — impersonation risk is the actual point of the badge
meetsCompleteProfile Boolean? // real name, bio, avatar set
meetsGoodStanding Boolean? // no active ban, no open warnings
meetsEstablishedPresence Boolean? // account has existed a while and actually posted
reviewNote String? @db.VarChar(1000)
reviewedBy String? // ownerId of the moderator who decided
reviewedAt DateTime?
createdAt DateTime @default(now())
@@index([status, createdAt(sort: Desc)])
@@index([petId])
}
model InviteCode {
id String @id @default(cuid())
code String @unique
@@ -144,6 +176,8 @@ model Pet {
adComments AdComment[] @relation("AdComments")
adReposts AdRepost[] @relation("AdReposts")
verificationRequests VerificationRequest[]
@@index([ownerId])
@@index([speciesId])
@@index([breedId])
@@ -652,7 +686,7 @@ model AdRepost {
model ModerationLog {
id String @id @default(cuid())
action String @db.VarChar(50) // DELETE_POST | DELETE_COMMENT | BAN_USER | UNBAN_USER | DELETE_IMAGE | DISMISS_REPORT | CREATE_AD | UPDATE_AD | DELETE_AD | GRANT_ROLE | REVOKE_ROLE | WARN_USER | VERIFY_PET | UNVERIFY_PET | DELETE_ACCOUNT
action String @db.VarChar(50) // DELETE_POST | DELETE_COMMENT | BAN_USER | UNBAN_USER | DELETE_IMAGE | DISMISS_REPORT | CREATE_AD | UPDATE_AD | DELETE_AD | GRANT_ROLE | REVOKE_ROLE | WARN_USER | VERIFY_PET | UNVERIFY_PET | DELETE_ACCOUNT | APPROVE_VERIFICATION_REQUEST | REJECT_VERIFICATION_REQUEST
targetType String @db.VarChar(20) // POST | COMMENT | USER | IMAGE | AD | REPORT | PET
targetId String
reason String? @db.VarChar(500)