// R-P7 · P7 Lead-Inbox — typed lead intake domain (AD-20). // // AD-21: this module owns its schema file. Cross-module references to Kontakt, // Projekt and User are intentionally bare String scalars so P7 can land without // touching crm.prisma/accounts.prisma or a not-yet-existing project schema. // App-level isolation runs through leadService + withTenantRLS(); the deferred // RLS rollout artifact lives in prisma/rls/leads-isolation.sql. enum LeadQuelle { form email aircall manual custom } enum InboxLeadStatus { new qualified converted lost spam } enum LeadWeiterverarbeitungFreigabe { ja nein unklar } enum LeadSourceType { system custom } enum LeadAntiSpamMode { quarantine spam } model InboxLead { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt tenantId String createdByUserId String? zustaendigerUserId String? quelle LeadQuelle quelleDetail Json? sourceId String? sourceOrigin String? submitterIpHash String? status InboxLeadStatus @default(new) weiterverarbeitungFreigabe LeadWeiterverarbeitungFreigabe @default(unklar) vorname String? nachname String? email String? telefon String? message String? rohdaten Json? spamScore Int @default(0) spamReason String? isQuarantined Boolean @default(false) konvertiertProjektId String? verknuepfterKontaktId String? convertedAt DateTime? lostAt DateTime? spamMarkedAt DateTime? autoDeleteAt DateTime? isDemoData Boolean @default(false) archivedAt DateTime? source LeadSource? @relation(fields: [sourceId], references: [id], onDelete: SetNull) @@index([tenantId, status, createdAt]) @@index([tenantId, quelle, createdAt]) @@index([tenantId, sourceId, createdAt]) @@index([tenantId, submitterIpHash, createdAt]) @@index([tenantId, zustaendigerUserId, status]) @@index([tenantId, email]) @@index([tenantId, telefon]) @@index([tenantId, autoDeleteAt]) } model LeadSource { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt tenantId String type LeadSourceType key String name String displayLabel String defaultZustaendigerUserId String? defaultTags Json? webhookTokenHash String? pausedAt DateTime? archivedAt DateTime? isDemoData Boolean @default(false) leads InboxLead[] @@unique([tenantId, key]) @@index([tenantId, type, archivedAt]) } model LeadAntiSpamConfig { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt tenantId String @unique perSourcePerHourLimit Int @default(100) perIpPerHourLimit Int @default(30) anomalySpikeFactor Int @default(10) mode LeadAntiSpamMode @default(quarantine) disposableDomainEnabled Boolean @default(true) honeypotEnabled Boolean @default(true) fastSubmitEnabled Boolean @default(true) lostAutoDeleteDays Int @default(0) isDemoData Boolean @default(false) }