akf-forum/routes/messages.js

15 lines
457 B
JavaScript
Raw Normal View History

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) => {
const message = await MessageModel.get(req.params.id);
2022-03-21 23:53:22 +03:00
2022-08-11 00:49:44 +03:00
if (!message || (message.deleted && req.user && !req.user.admin)) return res.error( 404, "We have not got any message declared as this id.");
2022-08-11 18:34:35 +03:00
res.redirect("/threads/" + message.threadID+"?scroll="+req.params.id);
2022-03-21 23:53:22 +03:00
});
module.exports = app;