mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 13:20:41 +03:00
19 lines
551 B
JavaScript
19 lines
551 B
JavaScript
|
const { Thread, Message, User } = require("../../classes/index");
|
||
|
const error = require("../../errors/error.js")
|
||
|
|
||
|
module.exports = (req, res) => {
|
||
|
if (!req.session.loggedin) return res.redirect('/login');
|
||
|
|
||
|
const id = req.url.slice(9);
|
||
|
const thread = new Thread().getId(id);
|
||
|
|
||
|
if (thread) {
|
||
|
thread.push(new Message(req.body.content, new User().getId(req.session.userid)))
|
||
|
thread.write();
|
||
|
res.redirect('/threads/' + id);
|
||
|
|
||
|
}
|
||
|
else
|
||
|
error(res, 404, "We have not got this thread.");
|
||
|
|
||
|
}
|