diff --git a/functions/api/routes/room/roomTimelineGET.js b/functions/api/routes/room/roomTimelineGET.js index ffc6bf8..73bef05 100644 --- a/functions/api/routes/room/roomTimelineGET.js +++ b/functions/api/routes/room/roomTimelineGET.js @@ -69,6 +69,8 @@ module.exports = async (req, res) => { return timeline; }); + await lifeTimelineDB.readLifeTimeline(client, roomId, user.userId); + return res.status(statusCode.OK).send( util.success(statusCode.OK, responseMessage.GET_LIFE_TIMELINE_SUCCESS, { timelines, diff --git a/functions/constants/responseMessage.js b/functions/constants/responseMessage.js index 5171ff1..5ab35e7 100644 --- a/functions/constants/responseMessage.js +++ b/functions/constants/responseMessage.js @@ -69,6 +69,7 @@ module.exports = { // Life Timeline GET_LIFE_TIMELINE_SUCCESS: '생명 타임라인 조회 성공', + LIFE_TIMELINE_READ_SUCCESS: '생명 타임라인 읽음처리 완료', // Feed GET_FEED_SUCCES: '피드 조회 성공', diff --git a/functions/db/lifeTimeline.js b/functions/db/lifeTimeline.js index 74f2072..39633ee 100644 --- a/functions/db/lifeTimeline.js +++ b/functions/db/lifeTimeline.js @@ -28,7 +28,22 @@ const getLifeTimeline = async (client, roomId, userId) => { return convertSnakeToCamel.keysToCamel(rows); }; +const readLifeTimeline = async (client, roomId, userId) => { + const { rows } = await client.query( + ` + UPDATE spark.life_timeline + SET is_read = TRUE + WHERE room_id = $1 + AND receiver_id = $2 + RETURNING * + `, + [roomId, userId], + ); + return convertSnakeToCamel.keysToCamel(rows); +}; + module.exports = { addLifeTimeline, getLifeTimeline, + readLifeTimeline, };