Skip to content
Merged
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
30 changes: 30 additions & 0 deletions backend/controllers/questionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ const togglePinQuestion = async (req, res) => {
.status(404)
.json({ success: false, message: "Question not found" });
}

const session = await Session.findById(question.session);
if (!session) {
return res
.status(404)
.json({ success: false, message: "Session not found" });
}

if (session.user.toString() !== req.user.id) {
return res.status(403).json({
success: false,
message: "Unauthorized access",
});
}

question.isPinned = !question.isPinned;
await question.save();

Expand Down Expand Up @@ -104,6 +119,21 @@ const updateQuestionNote = async (req, res) => {
.status(404)
.json({ success: false, message: "Question not found" });
}

const session = await Session.findById(question.session);
if (!session) {
return res
.status(404)
.json({ success: false, message: "Session not found" });
}

if (session.user.toString() !== req.user.id) {
return res.status(403).json({
success: false,
message: "Unauthorized access",
});
}

question.note = note || "";
await question.save();

Expand Down