Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 생명 타임라인 읽음 처리 기능 구현 #434

Merged
merged 3 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};