mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 21:30:42 +03:00
String fixes
This commit is contained in:
parent
141b994756
commit
5414271924
6 changed files with 17 additions and 18 deletions
|
@ -71,6 +71,7 @@ And, you can learn about API in `util/APIDOCS.md`.
|
||||||
| To do | Is done? | Priority |
|
| To do | Is done? | Priority |
|
||||||
| ----- | -------- | -------- |
|
| ----- | -------- | -------- |
|
||||||
| Footer | 🟡 | LOW |
|
| Footer | 🟡 | LOW |
|
||||||
|
| auto-scroll | 🟡 | LOW |
|
||||||
| Multi-theme support | 🔴 | LOW |
|
| Multi-theme support | 🔴 | LOW |
|
||||||
| Search | 🔴 | MEDIUM |
|
| Search | 🔴 | MEDIUM |
|
||||||
| Better view | 🟢 | MEDIUM |
|
| Better view | 🟢 | MEDIUM |
|
||||||
|
|
|
@ -57,6 +57,7 @@ function renderMessage(message) {
|
||||||
|
|
||||||
renderMessage(message);
|
renderMessage(message);
|
||||||
}
|
}
|
||||||
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ const app = Router();
|
||||||
app.get("/", async (req, res) => {
|
app.get("/", async (req, res) => {
|
||||||
const
|
const
|
||||||
mem = process.memoryUsage().heapUsed / Math.pow(2, 20),
|
mem = process.memoryUsage().heapUsed / Math.pow(2, 20),
|
||||||
users = await UserModel.count({}),
|
users = await UserModel.count({deleted:false}),
|
||||||
threads = await ThreadModel.count({}),
|
threads = await ThreadModel.count({deleted:false}),
|
||||||
messages = await MessageModel.count({}),
|
messages = await MessageModel.count({deleted:false}),
|
||||||
user = req.user;
|
user = req.user;
|
||||||
|
|
||||||
res.render("index", { mem, user, users, threads, messages })
|
res.render("index", { mem, user, users, threads, messages })
|
||||||
|
|
|
@ -8,12 +8,9 @@ const app = Router();
|
||||||
|
|
||||||
app.get("/:id", async (req, res) => {
|
app.get("/:id", async (req, res) => {
|
||||||
|
|
||||||
|
|
||||||
const { id = null } = req.params;
|
|
||||||
if (!id) return res.error(400, "Missing id in query")
|
|
||||||
const message = await MessageModel.get(id);
|
const message = await MessageModel.get(id);
|
||||||
|
|
||||||
if (!message || (message.deleted && req.user && !req.user.admin)) return res.error(404, "We have not got any message declared as this id.");
|
if (!message || (message.deleted && req.user && !req.user.admin)) return res.error(404, `We don't have any thread with id ${id}.`);
|
||||||
|
|
||||||
res.complate(message);
|
res.complate(message);
|
||||||
|
|
||||||
|
@ -32,7 +29,7 @@ app.post("/", rateLimit({
|
||||||
|
|
||||||
const thread = await ThreadModel.get(threadID);
|
const thread = await ThreadModel.get(threadID);
|
||||||
|
|
||||||
if (!thread) return res.error(404, "We have not got this thread.");
|
if (!thread) return res.error(404, `We don't have any thread with id ${threadID}.`);
|
||||||
|
|
||||||
const message = await new MessageModel({ content, author: req.user, threadID: thread.id }).takeId();
|
const message = await new MessageModel({ content, author: req.user, threadID: thread.id }).takeId();
|
||||||
await message.save();
|
await message.save();
|
||||||
|
@ -55,7 +52,7 @@ app.post("/:id/react/:type", async (req, res) => {
|
||||||
|
|
||||||
const arr = Object.values(message.react)
|
const arr = Object.values(message.react)
|
||||||
res.complate(arr.filter(Boolean).length - arr.filter(x => !x).length)
|
res.complate(arr.filter(Boolean).length - arr.filter(x => !x).length)
|
||||||
} else error(res, 404, "We have not got this Message for reacting.");
|
} else error(res, 404, `We don't have any message with id ${req.params.id}.`);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ app.get("/:id", async (req, res) => {
|
||||||
if (thread && (req.user?.admin || !thread.deleted))
|
if (thread && (req.user?.admin || !thread.deleted))
|
||||||
res.complate(thread);
|
res.complate(thread);
|
||||||
else
|
else
|
||||||
return res.error(404, "We don't have any thread with this id.");
|
return res.error(404, `We don't have any thread with id ${id}.`);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ app.get("/:id", async (req, res) => {
|
||||||
app.get("/:id/messages/", async (req, res) => {
|
app.get("/:id/messages/", async (req, res) => {
|
||||||
|
|
||||||
|
|
||||||
const { id = null } = req.params;
|
const { id } = req.params;
|
||||||
const limit = Number(req.query.limit);
|
const limit = Number(req.query.limit);
|
||||||
|
|
||||||
const query = { threadID: id };
|
const query = { threadID: id };
|
||||||
|
@ -54,7 +54,7 @@ app.post("/", async (req, res) => {
|
||||||
|
|
||||||
app.post("/:id/delete", async (req, res) => {
|
app.post("/:id/delete", async (req, res) => {
|
||||||
const thread = await ThreadModel.get(req.params.id);
|
const thread = await ThreadModel.get(req.params.id);
|
||||||
if (!thread || thread.deleted) return res.error(404, "We don't have any thread with this id.");
|
if (!thread || thread.deleted) return res.error(404, `We don't have any thread with id ${req.params.id}.`);
|
||||||
const user = req.user;
|
const user = req.user;
|
||||||
if (user.id != thread.authorID && !user.admin)
|
if (user.id != thread.authorID && !user.admin)
|
||||||
return res.error(403, "You have not got permission for this.");
|
return res.error(403, "You have not got permission for this.");
|
||||||
|
|
|
@ -6,9 +6,9 @@ const app = Router();
|
||||||
app.get("/:id", async (req, res) => {
|
app.get("/:id", async (req, res) => {
|
||||||
|
|
||||||
const { id = null } = req.params;
|
const { id = null } = req.params;
|
||||||
if (!id) return res.error(400, "Missing id in query")
|
|
||||||
const member = await UserModel.get(id);
|
const member = await UserModel.get(id);
|
||||||
if (!member || (member.deleted && !req.user.admin)) return res.error(404, "We have not got any user declared as this id.");
|
if (!member || (member.deleted && !req.user.admin)) return res.error(404, `We don't have any user with id ${id}.`);
|
||||||
|
|
||||||
res.complate(member);
|
res.complate(member);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ app.post("/:id/delete/", async (req, res) => {
|
||||||
const { id = null } = req.params;
|
const { id = null } = req.params;
|
||||||
const member = await UserModel.get(id);
|
const member = await UserModel.get(id);
|
||||||
|
|
||||||
if (!member || member.deleted) return res.error(404, "We have not got any user declared as this id.");
|
if (!member || member.deleted) return res.error(404, `We don't have any user with id ${id}.`);
|
||||||
|
|
||||||
member.deleted = true;
|
member.deleted = true;
|
||||||
await member.save();
|
await member.save();
|
||||||
|
@ -33,11 +33,11 @@ app.post("/:id/admin/", async (req, res) => {
|
||||||
|
|
||||||
const user = req.user;
|
const user = req.user;
|
||||||
|
|
||||||
if (!user.admin) return res.error(403, "You have not got permissions for view to this page.");
|
if (!user.admin) return res.error(403, "You have not got permission for this.");
|
||||||
const user2 = await UserModel.get(req.params.id);
|
const user2 = await UserModel.get(req.params.id);
|
||||||
|
|
||||||
if (!user2)
|
if (!user2)
|
||||||
return res.error(404, "This user is not available.");
|
return res.error(404, `We don't have any user with id ${id}.`);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
user2.admin = true;
|
user2.admin = true;
|
||||||
|
|
Loading…
Reference in a new issue