Skip to content

Commit

Permalink
Merge pull request #434 from TeamSparker/feature/#432
Browse files Browse the repository at this point in the history
[FEAT] 생명 타임라인 읽음 처리 기능 구현
  • Loading branch information
youngkwon02 authored Sep 27, 2022
2 parents 8d745a5 + 5922976 commit c095f96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions functions/api/routes/room/roomTimelineGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions functions/constants/responseMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module.exports = {

// Life Timeline
GET_LIFE_TIMELINE_SUCCESS: '생명 타임라인 조회 성공',
LIFE_TIMELINE_READ_SUCCESS: '생명 타임라인 읽음처리 완료',

// Feed
GET_FEED_SUCCES: '피드 조회 성공',
Expand Down
15 changes: 15 additions & 0 deletions functions/db/lifeTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit c095f96

Please sign in to comment.