Add unsend campaign feature (#45)

* Add unsend email editor

Add email editor

Add more email editor

Add renderer partial

Add more marketing email features

* Add more campaign feature

* Add variables

* Getting there

* campaign is there mfs

* Add migration
This commit is contained in:
KM Koushik
2024-08-10 10:09:10 +10:00
committed by GitHub
parent 0c072579b9
commit 5ddc0a7bb9
92 changed files with 11766 additions and 338 deletions

View File

@@ -4,9 +4,45 @@ import * as tldts from "tldts";
import * as ses from "~/server/aws/ses";
import { db } from "~/server/db";
import { SesSettingsService } from "./ses-settings-service";
import { UnsendApiError } from "../public-api/api-error";
const dnsResolveTxt = util.promisify(dns.resolveTxt);
export async function validateDomainFromEmail(email: string, teamId: number) {
let fromDomain = email.split("@")[1];
if (fromDomain?.endsWith(">")) {
fromDomain = fromDomain.slice(0, -1);
}
if (!fromDomain) {
throw new UnsendApiError({
code: "BAD_REQUEST",
message: "From email is invalid",
});
}
const domain = await db.domain.findUnique({
where: { name: fromDomain, teamId },
});
if (!domain) {
throw new UnsendApiError({
code: "BAD_REQUEST",
message:
"Domain of from email is wrong. Use the domain verified by unsend",
});
}
if (domain.status !== "SUCCESS") {
throw new UnsendApiError({
code: "BAD_REQUEST",
message: "Domain is not verified",
});
}
return domain;
}
export async function createDomain(
teamId: number,
name: string,