-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba02724
commit 5164a13
Showing
4 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 27 additions & 9 deletions
36
src/modules/apiRequests/changeCommentStatus/changeCommentStatus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
const { log } = require("../../../services/logger/logger"); | ||
const { db } = require("../../dbRequests/mongo"); | ||
const { generateMessage } = require("../../../utils/messageGenerator"); | ||
|
||
function changeCommentStatus({ userId, taskId, status }) { | ||
return db.STATE.findOneAndUpdate( | ||
{ userId, taskId }, | ||
{ | ||
$set: { | ||
"comments.0.readedByTeacher": status, | ||
async function changeCommentStatus({ req, res }) { | ||
|
||
const {userId, taskId, status = false} = req.body | ||
|
||
try { | ||
await db.STATE.findOneAndUpdate( | ||
{ userId, taskId }, | ||
{ | ||
$set: { | ||
"comments.0.readedByTeacher": status, | ||
}, | ||
}, | ||
}, | ||
{ upsert: true, returnDocument: "after", returnNewDocument: true } | ||
); | ||
{ upsert: true, returnDocument: "after", returnNewDocument: true } | ||
); | ||
|
||
const data = generateMessage(0); | ||
res.status(200).send(data); | ||
|
||
return data; | ||
} catch (e) { | ||
log.warn(`Error with updating comment status for user ${userId} and task ${taskId}`); | ||
log.warn(e); | ||
const error = generateMessage(20115); | ||
res.status(400).send(error); | ||
} | ||
|
||
|
||
} | ||
|
||
module.exports.changeCommentStatus = changeCommentStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters