fix: don't remind platform users in reminder cron (#20056)
This commit is contained in:
@@ -55,6 +55,8 @@ async function postHandler(request: NextRequest) {
|
||||
locale: true,
|
||||
timeZone: true,
|
||||
destinationCalendar: true,
|
||||
isPlatformManaged: true,
|
||||
platformOAuthClients: { select: { id: true, areEmailsEnabled: true } },
|
||||
},
|
||||
},
|
||||
eventType: {
|
||||
@@ -70,11 +72,18 @@ async function postHandler(request: NextRequest) {
|
||||
},
|
||||
});
|
||||
|
||||
const bookingsToRemind = bookings.filter(
|
||||
(booking) =>
|
||||
!booking.user ||
|
||||
!booking.user.isPlatformManaged ||
|
||||
(booking.user.isPlatformManaged && Boolean(booking.user.platformOAuthClients?.[0]?.areEmailsEnabled))
|
||||
);
|
||||
|
||||
const reminders = await prisma.reminderMail.findMany({
|
||||
where: {
|
||||
reminderType: ReminderType.PENDING_BOOKING_CONFIRMATION,
|
||||
referenceId: {
|
||||
in: bookings.map((b) => b.id),
|
||||
in: bookingsToRemind.map((b) => b.id),
|
||||
},
|
||||
elapsedMinutes: {
|
||||
gte: interval,
|
||||
|
||||
Reference in New Issue
Block a user