mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
✨ Message delete route
This commit is contained in:
parent
fe8a1c1000
commit
371dbf25c9
@ -1,6 +1,23 @@
|
|||||||
|
import { ChannelModel, getPermission, MessageModel } from "@fosscord/server-util";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
import { HTTPError } from "lambert-server";
|
||||||
|
import { check } from "../../../../../util/instanceOf";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
// TODO:
|
// TODO:
|
||||||
|
|
||||||
|
router.delete("/", async (req, res) => {
|
||||||
|
const { message_id, channel_id } = req.params;
|
||||||
|
|
||||||
|
const channel = await ChannelModel.findOne({ id: channel_id }, { guild_id: true });
|
||||||
|
if (!channel) throw new HTTPError("Channel doesn't exist", 404);
|
||||||
|
|
||||||
|
const permission = await getPermission(req.user_id, channel.guild_id, channel_id);
|
||||||
|
permission.hasThrow("MANAGE_MESSAGES");
|
||||||
|
|
||||||
|
await MessageModel.deleteOne({ id: message_id }).exec();
|
||||||
|
|
||||||
|
res.sendStatus(204);
|
||||||
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
Loading…
Reference in New Issue
Block a user