2022-08-11 00:38:44 +03:00
|
|
|
const { MessageModel } = require("../models");
|
2022-03-21 23:53:22 +03:00
|
|
|
|
|
|
|
const { Router } = require("express");
|
|
|
|
|
|
|
|
const app = Router();
|
|
|
|
|
2022-04-06 21:14:46 +03:00
|
|
|
app.get("/:id", async (req, res) => {
|
2022-08-09 19:16:34 +03:00
|
|
|
const message = await MessageModel.get(req.params.id);
|
2022-03-21 23:53:22 +03:00
|
|
|
|
2022-08-29 16:16:44 +03:00
|
|
|
if (!message || (message.deleted && req.user && !req.user.admin)) return res.error( 404,
|
|
|
|
`We don't have any message with id ${req.params.id}.`);
|
|
|
|
res.redirect(`/threads/${message.threadID}?scroll=${req.params.id}`);
|
2022-03-21 23:53:22 +03:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = app;
|