fix: validate shared link refresh payload

This commit is contained in:
Danny Avila 2026-05-12 15:17:50 -04:00
parent 23053f015a
commit a5b7e07434
2 changed files with 6 additions and 1 deletions

View file

@ -114,6 +114,10 @@ router.post('/:conversationId', requireJwtAuth, async (req, res) => {
router.patch('/:shareId', requireJwtAuth, async (req, res) => {
try {
const { targetMessageId } = req.body ?? {};
if (targetMessageId !== undefined && typeof targetMessageId !== 'string') {
return res.status(400).json({ message: 'targetMessageId must be a string' });
}
const updatedShare = await updateSharedLink(req.user.id, req.params.shareId, targetMessageId);
if (updatedShare) {
res.status(200).json(updatedShare);

View file

@ -319,7 +319,8 @@ export type TSharedLinkResponse = Pick<TSharedLink, 'shareId'> &
Pick<TSharedLink, 'targetMessageId'> &
Pick<TConversation, 'conversationId'>;
export type TSharedLinkGetResponse = TSharedLinkResponse & {
export type TSharedLinkGetResponse = Omit<TSharedLinkResponse, 'shareId'> & {
shareId: string | null;
success: boolean;
};