File tree 1 file changed +10
-1
lines changed
apps/web/app/api/cron/bookingReminder
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ async function postHandler(request: NextRequest) {
55
55
locale : true ,
56
56
timeZone : true ,
57
57
destinationCalendar : true ,
58
+ isPlatformManaged : true ,
59
+ platformOAuthClients : { select : { id : true , areEmailsEnabled : true } } ,
58
60
} ,
59
61
} ,
60
62
eventType : {
@@ -70,11 +72,18 @@ async function postHandler(request: NextRequest) {
70
72
} ,
71
73
} ) ;
72
74
75
+ const bookingsToRemind = bookings . filter (
76
+ ( booking ) =>
77
+ ! booking . user ||
78
+ ! booking . user . isPlatformManaged ||
79
+ ( booking . user . isPlatformManaged && Boolean ( booking . user . platformOAuthClients ?. [ 0 ] ?. areEmailsEnabled ) )
80
+ ) ;
81
+
73
82
const reminders = await prisma . reminderMail . findMany ( {
74
83
where : {
75
84
reminderType : ReminderType . PENDING_BOOKING_CONFIRMATION ,
76
85
referenceId : {
77
- in : bookings . map ( ( b ) => b . id ) ,
86
+ in : bookingsToRemind . map ( ( b ) => b . id ) ,
78
87
} ,
79
88
elapsedMinutes : {
80
89
gte : interval ,
You can’t perform that action at this time.
0 commit comments