\n => <br>

This commit is contained in:
Akif9748 2022-08-24 22:39:38 +03:00
parent c9433e175a
commit 8ee97ea497
7 changed files with 10 additions and 17 deletions

View file

@ -43,6 +43,7 @@ And, you can learn about API in `util/APIDOCS.md`.
| Ratelimit | 🟢 | HIGH |
| Send | 🟢 | HIGH |
| Delete | 🟢 | HIGH |
| Regex for scripts | 🔴 | HIGH |
| Undelete | 🔴 | MEDIUM |
| React | 🟢 | MEDIUM |
| Edit | 🔴 | MEDIUM |

View file

@ -16,7 +16,7 @@ function renderMessage(message) {
<a href=${"/users/" + message.author.id}> ${message.author.name}</a>:
</h2>
<p>${message.content}</p><br>
<p>${message.content.replaceAll("\n","<br>")}</p><br>
<div id="message-delete-${message.id}">
${!message.deleted ?
`<form style="display:inline;">
@ -49,14 +49,9 @@ function renderMessage(message) {
} else
for (const message of result) {
const arr = Object.values(message.react || {})
message.reactCount = arr.filter(Boolean).length - arr.filter(x => !x).length;
for (const message of result)
renderMessage(message);
}
window.scrollTo(0, document.body.scrollHeight);
})();

View file

@ -1,6 +1,7 @@
const { UserModel, SecretModel } = require("../models");
const { Router } = require("express")
const bcrypt = require("bcrypt");
const rateLimit = require('express-rate-limit')
const app = Router();

View file

@ -1,6 +1,5 @@
const { Router } = require("express");
const app = Router();
const rateLimit = require('express-rate-limit')
const { ThreadModel, MessageModel } = require("../models")
@ -32,11 +31,8 @@ app.get("/:id", async (req, res) => {
if (thread && (user?.admin || !thread.deleted)) {
const messages = await Promise.all(thread.messages.map(async id => {
const message = await MessageModel.get(id)
const arr = Object.values(message.react)
message.reactCount = arr.filter(Boolean).length - arr.filter(x => !x).length;
return user?.admin || !message?.deleted ? message : null;
const message = await MessageModel.get(id)
return user?.admin || !message?.deleted ? message.toObject({ virtuals: true }) : null;
}));
res.render("thread", { thread, messages, user,scroll:req.query.scroll || false });

View file

@ -32,7 +32,7 @@ You need this headers for send request to API:
- POST `/api/messages/:id/react/:type` for react to a message.
### Example request:
```GET /api/message/1```
```GET /api/messages/1```
#### Example API Output:
```json

View file

@ -5,8 +5,8 @@
<body>
<%- include("extra/navbar") %>
<% if (user) { %>
<% if (user) { %>
<h1>Welcome, <a href=<%=user.getLink() %>> <%= user.name %></a>
<img class="circle" src=<%=user.avatar %> alt=<%= user.name %>>
<br>