fix: add multi email transport system (#2942)

This commit is contained in:
David Nguyen
2026-06-05 21:19:20 +10:00
committed by GitHub
parent ebf5b75a19
commit 4ee789ea37
67 changed files with 2440 additions and 115 deletions
@@ -0,0 +1,28 @@
-- CreateEnum
CREATE TYPE "EmailTransportType" AS ENUM ('SMTP_AUTH', 'SMTP_API', 'RESEND', 'MAILCHANNELS');
-- AlterTable
ALTER TABLE "OrganisationClaim" ADD COLUMN "emailTransportId" TEXT;
-- AlterTable
ALTER TABLE "SubscriptionClaim" ADD COLUMN "emailTransportId" TEXT;
-- CreateTable
CREATE TABLE "EmailTransport" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"type" "EmailTransportType" NOT NULL,
"fromName" TEXT NOT NULL,
"fromAddress" TEXT NOT NULL,
"config" TEXT NOT NULL,
CONSTRAINT "EmailTransport_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "SubscriptionClaim" ADD CONSTRAINT "SubscriptionClaim_emailTransportId_fkey" FOREIGN KEY ("emailTransportId") REFERENCES "EmailTransport"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "OrganisationClaim" ADD CONSTRAINT "OrganisationClaim_emailTransportId_fkey" FOREIGN KEY ("emailTransportId") REFERENCES "EmailTransport"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+32
View File
@@ -280,6 +280,9 @@ model SubscriptionClaim {
apiRateLimits Json /// [RateLimitArray] @zod.custom.use(ZRateLimitArraySchema)
apiQuota Int?
emailTransportId String?
emailTransport EmailTransport? @relation(fields: [emailTransportId], references: [id], onDelete: SetNull)
}
/// @zod.import(["import { ZClaimFlagsSchema, ZRateLimitArraySchema } from '@documenso/lib/types/subscription';"])
@@ -306,6 +309,9 @@ model OrganisationClaim {
apiRateLimits Json /// [RateLimitArray] @zod.custom.use(ZRateLimitArraySchema)
apiQuota Int?
emailTransportId String?
emailTransport EmailTransport? @relation(fields: [emailTransportId], references: [id], onDelete: SetNull)
}
model OrganisationMonthlyStat {
@@ -1136,6 +1142,32 @@ model OrganisationEmail {
teamGlobalSettings TeamGlobalSettings[]
}
enum EmailTransportType {
SMTP_AUTH
SMTP_API
RESEND
MAILCHANNELS
}
model EmailTransport {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
type EmailTransportType
// Required from-address override (plaintext, non-secret).
fromName String
fromAddress String
// Encrypted JSON blob of the full transport config (secrets + non-secrets).
config String
subscriptionClaims SubscriptionClaim[]
organisationClaims OrganisationClaim[]
}
model OrganisationAuthenticationPortal {
id String @id
organisation Organisation?