diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-05 01:17:00 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-10-05 01:30:37 +1100 |
commit | f35c8a1f49b8dab56a3ca3ae4a9dd677f3bfc43e (patch) | |
tree | f3ac4539bfe7e0dc183355e7824df80d67b2bb2d | |
parent | Add the automatic install script, thanks @Haydaralqassam (diff) | |
download | server-f35c8a1f49b8dab56a3ca3ae4a9dd677f3bfc43e.tar.xz |
Check nonce in Message send
-rw-r--r-- | src/api/routes/channels/#channel_id/messages/index.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts index 747701db..e0c91b8a 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts @@ -201,6 +201,19 @@ router.post( ); } + if (body.nonce) { + const existing = await Message.findOne({ + where: { + nonce: body.nonce, + channel_id: channel.id, + author_id: req.user_id + } + }); + if (existing) { + return res.json(existing); + } + } + const files = (req.files as Express.Multer.File[]) ?? []; for (var currFile of files) { try { |