Skip to content

Commit 8584ae0

Browse files
committed
feat: update existing unlinked guest record with new data and adjust response for web submissions
1 parent 05977b6 commit 8584ae0

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/routes/whatsappRoute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ router.post('/send-group-message', verifyIdToken, upload.single('image'), async
218218
const fileName = `${Date.now()}-${req.file.originalname}`;
219219
const uploadResult = await uploadFile(req.file.buffer, fileName, 'whatsapp-media', req.file.mimetype);
220220
if (uploadResult.success && uploadResult.url) {
221-
mediaUrl = uploadResult.url;
221+
mediaUrl = uploadResult.url; // This is correct - uploadResult.url is already a string
222222
} else {
223223
return res.status(500).json({ message: 'Failed to upload image.', error: uploadResult.error });
224224
}

src/services/inviteService.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,42 @@ export const submitGroupRsvp = async (
427427
});
428428

429429
if (existingUnlinkedGuest) {
430-
// Do not allow updates via web; instruct user to use the app
430+
431+
// Update existing unlinked guest record
432+
const updatedGuest = await tx.guest.update({
433+
where: { id: existingUnlinkedGuest.id },
434+
data: {
435+
rsvp: data.rsvp,
436+
name: data.name,
437+
email: data.email,
438+
...(data.food && { food: data.food }),
439+
...(typeof data.alcohol === 'boolean' && { alcohol: data.alcohol }),
440+
...(data.personal_note !== undefined && { personal_note: data.personal_note }),
441+
...(data.pickup_date_time && { pickup_date_time: data.pickup_date_time }),
442+
...(data.pickup_location && { pickup_location: data.pickup_location }),
443+
...(data.dropoff_date_time && { dropoff_date_time: data.dropoff_date_time }),
444+
...(data.dropoff_location && { dropoff_location: data.dropoff_location }),
445+
...(data.count && { count: data.count }),
446+
},
447+
include: {
448+
event: {
449+
select: {
450+
id: true,
451+
title: true,
452+
start_date_time: true
453+
}
454+
},
455+
group: { select: { id: true, name: true } }
456+
}
457+
});
458+
431459
return {
432-
guest: existingUnlinkedGuest,
460+
guest: updatedGuest,
433461
user: null,
434462
isNewUser: false,
435463
wasAuthenticated: false,
436464
isWebSubmission: true,
437-
alreadySubmitted: true
465+
alreadySubmitted: false
438466
};
439467
} else {
440468
// Create new unlinked guest record for web submission

0 commit comments

Comments
 (0)