feat(platform): checkpoint current implementation state
This commit is contained in:
@@ -47,7 +47,10 @@ function requireImmediateBroadcastTransaction(
|
||||
function buildBroadcastCreateData(
|
||||
senderId: string,
|
||||
input: z.infer<typeof CreateBroadcastInputSchema>,
|
||||
recipientCount?: number,
|
||||
options: {
|
||||
includeScheduledAt?: boolean;
|
||||
recipientCount?: number;
|
||||
} = {},
|
||||
) {
|
||||
return {
|
||||
senderId,
|
||||
@@ -59,8 +62,10 @@ function buildBroadcastCreateData(
|
||||
channel: input.channel,
|
||||
targetType: input.targetType,
|
||||
...(input.targetValue !== undefined ? { targetValue: input.targetValue } : {}),
|
||||
...(input.scheduledAt !== undefined ? { scheduledAt: input.scheduledAt } : {}),
|
||||
...(recipientCount !== undefined ? { recipientCount } : {}),
|
||||
...(options.includeScheduledAt && input.scheduledAt !== undefined
|
||||
? { scheduledAt: input.scheduledAt }
|
||||
: {}),
|
||||
...(options.recipientCount !== undefined ? { recipientCount: options.recipientCount } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,7 +98,10 @@ async function createScheduledBroadcastRecord(
|
||||
recipientIds: string[],
|
||||
) {
|
||||
return db.notificationBroadcast.create({
|
||||
data: buildBroadcastCreateData(senderId, input, recipientIds.length),
|
||||
data: buildBroadcastCreateData(senderId, input, {
|
||||
includeScheduledAt: true,
|
||||
recipientCount: recipientIds.length,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -183,7 +191,7 @@ export async function createBroadcast(
|
||||
try {
|
||||
return await createScheduledBroadcastRecord(ctx.db, senderId, input, recipientIds);
|
||||
} catch (error) {
|
||||
rethrowNotificationReferenceError(error);
|
||||
rethrowNotificationReferenceError(error, "broadcast");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +206,7 @@ export async function createBroadcast(
|
||||
persistedBroadcast = transactionResult.broadcast;
|
||||
notificationIds = transactionResult.notificationIds;
|
||||
} catch (error) {
|
||||
rethrowNotificationReferenceError(error);
|
||||
rethrowNotificationReferenceError(error, "broadcast");
|
||||
}
|
||||
|
||||
emitImmediateBroadcastSideEffects(ctx.db, input, notificationIds);
|
||||
|
||||
Reference in New Issue
Block a user