diff options
author | Erkin Alp Güney <erkinalp9035@gmail.com> | 2022-04-24 11:40:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 11:40:24 +0300 |
commit | e68e4639ff054c87d1182c58d2686c4f3e6f1b6c (patch) | |
tree | dc711100dac2ff3d75a0a57a936351061c13cf42 | |
parent | refine error codes for backfill constraint violations (diff) | |
download | server-e68e4639ff054c87d1182c58d2686c4f3e6f1b6c.tar.xz |
use return codes to allow for automation
-rw-r--r-- | api/src/routes/channels/#channel_id/messages/#message_id/index.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts index cf25f916..958954b6 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts @@ -2,13 +2,16 @@ import { Attachment, Channel, Embed, + DiscordApiErrors, emitEvent, + FosscordApiErrors, getPermission, getRights, Message, MessageCreateEvent, MessageDeleteEvent, MessageUpdateEvent, + Snowflake, uploadFile } from "@fosscord/util"; import { Router, Response, Request } from "express"; @@ -16,7 +19,6 @@ import multer from "multer"; import { route } from "@fosscord/api"; import { handleMessage, postHandleMessage } from "@fosscord/api"; import { MessageCreateSchema } from "../index"; -import { Snowflake } from "@fosscord/util"; import { HTTPError } from "lambert-server"; const router = Router(); @@ -104,12 +106,12 @@ router.put( const snowflake = Snowflake.deconstruct(message_id) if (Date.now() < snowflake.timestamp) { // message is in the future - throw new HTTPError("You cannot backfill messages in the future", 400); + throw FosscordApiErrors.CANNOT_BACKFILL_TO_THE_FUTURE; } const exists = await Message.findOne({ where: { id: message_id, channel_id: channel_id }}); if (exists) { - throw new HTTPError("Cannot backfill to message ID that already exists", 409); + throw FosscordApiErrors.CANNOT_REPLACE_BY_BACKFILL; } if (req.file) { |