2 todo did.

This commit is contained in:
Akif9748 2022-08-09 19:48:10 +03:00
parent af649c0335
commit 086f2b5713
3 changed files with 4 additions and 7 deletions

View file

@ -22,9 +22,7 @@ And, you can learn about API in `util/APIDOCS.md`.
- `/errors/error` will change, better error page.
- Redirect query.
- middleware for timeouts
- DELETED USERS: USERLIST
- Will fix API
- if admin you van see deleted messages.
## Roadmap
### User

View file

@ -33,7 +33,7 @@ app.get("/:id", async (req, res) => {
const messages = await Promise.all(thread.messages.map(async id => {
const message = await MessageModel.get(id)
return (message.deleted || !message) ? null : message;
return (user.admin || !message?.deleted) ? message : null;
}));
res.render("thread", { thread, messages, user })

View file

@ -4,9 +4,8 @@ const app = Router();
const error = require("../errors/error");
const { UserModel, MessageModel, ThreadModel } = require("../models");
app.get("/", async (req, res) => {
const user = req.user
const users = await UserModel.find({ deleted: false });
app.get("/", async ({ user }, res) => {
const users = await UserModel.find(user.admin ? {} : { deleted: false });
return res.render("users", { users, user })
});
@ -21,7 +20,7 @@ app.get("/:id", async (req, res) => {
const message = await MessageModel.count({ authorID: id });
const thread = await ThreadModel.count({ authorID: id });
res.render("user", { user, member, counts:{ message, thread } })
res.render("user", { user, member, counts: { message, thread } })
}
else error(res, 404, "We have not got this user.");