fix campaign update not working
This commit is contained in:
@@ -27,7 +27,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
page: z.number().optional(),
|
page: z.number().optional(),
|
||||||
status: z.enum(statuses).optional().nullable(),
|
status: z.enum(statuses).optional().nullable(),
|
||||||
search: z.string().optional().nullable(),
|
search: z.string().optional().nullable(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ ctx: { db, team }, input }) => {
|
.query(async ({ ctx: { db, team }, input }) => {
|
||||||
const page = input.page || 1;
|
const page = input.page || 1;
|
||||||
@@ -95,7 +95,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
from: z.string(),
|
from: z.string(),
|
||||||
subject: z.string(),
|
subject: z.string(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ ctx: { db, team }, input }) => {
|
.mutation(async ({ ctx: { db, team }, input }) => {
|
||||||
const domain = await validateDomainFromEmail(input.from, team.id);
|
const domain = await validateDomainFromEmail(input.from, team.id);
|
||||||
@@ -122,11 +122,10 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
html: z.string().optional(),
|
html: z.string().optional(),
|
||||||
contactBookId: z.string().optional(),
|
contactBookId: z.string().optional(),
|
||||||
replyTo: z.string().array().optional(),
|
replyTo: z.string().array().optional(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ ctx: { db, team, campaign: campaignOld }, input }) => {
|
.mutation(async ({ ctx: { db, team, campaign: campaignOld }, input }) => {
|
||||||
const { html: htmlInput, ...data } = input;
|
const { html: htmlInput, campaignId, ...data } = input;
|
||||||
const campaignId = campaignOld.id;
|
|
||||||
if (data.contactBookId) {
|
if (data.contactBookId) {
|
||||||
const contactBook = await db.contactBook.findUnique({
|
const contactBook = await db.contactBook.findUnique({
|
||||||
where: { id: data.contactBookId },
|
where: { id: data.contactBookId },
|
||||||
@@ -224,7 +223,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return emails;
|
return emails;
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
reSubscribeContact: publicProcedure
|
reSubscribeContact: publicProcedure
|
||||||
@@ -232,7 +231,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
z.object({
|
z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
hash: z.string(),
|
hash: z.string(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
await campaignService.subscribeContact(input.id, input.hash);
|
await campaignService.subscribeContact(input.id, input.hash);
|
||||||
@@ -254,7 +253,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return newCampaign;
|
return newCampaign;
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
scheduleCampaign: campaignProcedure
|
scheduleCampaign: campaignProcedure
|
||||||
@@ -263,7 +262,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
campaignId: z.string(),
|
campaignId: z.string(),
|
||||||
scheduledAt: z.union([z.string().datetime(), z.date()]).optional(),
|
scheduledAt: z.union([z.string().datetime(), z.date()]).optional(),
|
||||||
batchSize: z.number().min(1).max(100_000).optional(),
|
batchSize: z.number().min(1).max(100_000).optional(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ ctx: { team }, input }) => {
|
.mutation(async ({ ctx: { team }, input }) => {
|
||||||
await campaignService.scheduleCampaign({
|
await campaignService.scheduleCampaign({
|
||||||
@@ -296,7 +295,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ ctx: { team }, input }) => {
|
.mutation(async ({ ctx: { team }, input }) => {
|
||||||
const extension = input.name.split(".").pop();
|
const extension = input.name.split(".").pop();
|
||||||
@@ -304,7 +303,7 @@ export const campaignRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const url = await getDocumentUploadUrl(
|
const url = await getDocumentUploadUrl(
|
||||||
`${team.id}/${randomName}`,
|
`${team.id}/${randomName}`,
|
||||||
input.type
|
input.type,
|
||||||
);
|
);
|
||||||
|
|
||||||
const imageUrl = `${env.S3_COMPATIBLE_PUBLIC_URL}/${team.id}/${randomName}`;
|
const imageUrl = `${env.S3_COMPATIBLE_PUBLIC_URL}/${team.id}/${randomName}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user