@replyke/express
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
34 lines (33 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../../../models");
exports.default = async (req, res) => {
try {
const loggedInUserId = req.userId;
const projectId = req.project.id;
const { notificationId } = req.params;
const updatedCount = await models_1.AppNotification.update({ isRead: true }, {
where: {
id: notificationId,
userId: loggedInUserId,
projectId,
},
});
if (updatedCount[0] === 0) {
res.status(404).json({
error: "Notification not found",
code: "app-notification/not-found",
});
return;
}
res.sendStatus(200);
}
catch (err) {
console.error("Error marking notification as read: ", err);
res.status(500).json({
error: "Internal server error.",
code: "app-notification/server-error",
details: err.message,
});
}
};