diff options
-rw-r--r-- | api/src/Server.ts | 2 | ||||
-rw-r--r-- | api/src/routes/guilds/#guild_id/emojis.ts | 5 | ||||
-rw-r--r-- | api/tsconfig.json | 3 | ||||
-rw-r--r-- | util/src/entities/ReadState.ts | 5 | ||||
-rw-r--r-- | util/src/entities/index.ts | 1 | ||||
-rw-r--r-- | util/src/util/cdn.ts | 4 |
6 files changed, 7 insertions, 13 deletions
diff --git a/api/src/Server.ts b/api/src/Server.ts index 1f11a295..a6887fd4 100644 --- a/api/src/Server.ts +++ b/api/src/Server.ts @@ -78,7 +78,7 @@ export class FosscordServer extends Server { api.use("*", (error: any, req: Request, res: Response, next: NextFunction) => { if (error) return next(error); res.status(404).json({ - message: "404: Not Found", + message: "404 endpoint not found", code: 0 }); next(); diff --git a/api/src/routes/guilds/#guild_id/emojis.ts b/api/src/routes/guilds/#guild_id/emojis.ts index ff565cd4..85d7ac05 100644 --- a/api/src/routes/guilds/#guild_id/emojis.ts +++ b/api/src/routes/guilds/#guild_id/emojis.ts @@ -40,17 +40,14 @@ router.post("/", route({ body: "EmojiCreateSchema", permission: "MANAGE_EMOJIS_A const { guild_id } = req.params; const body = req.body as EmojiCreateSchema; + const id = Snowflake.generate(); const emoji_count = await Emoji.count({ guild_id: guild_id }); const { maxEmojis } = Config.get().limits.guild; if (emoji_count >= maxEmojis) throw DiscordApiErrors.MAXIMUM_NUMBER_OF_EMOJIS_REACHED.withParams(maxEmojis); - - const id = Snowflake.generate(); - if (body.require_colons == null) body.require_colons = true; const user = await User.findOneOrFail({ id: req.user_id }); - body.image = (await handleFile(`/emojis/${id}`, body.image)) as string; const emoji = await new Emoji({ diff --git a/api/tsconfig.json b/api/tsconfig.json index 2cf4e4c1..80d7251f 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.json @@ -67,8 +67,7 @@ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "baseUrl": ".", "paths": { - "@fosscord/api": ["src/index"], - "@fosscord/api/*": ["src/*"] + "@fosscord/api": ["src/index"] }, "plugins": [{ "transform": "@zerollup/ts-transform-paths" }], "experimentalDecorators": true diff --git a/util/src/entities/ReadState.ts b/util/src/entities/ReadState.ts index 89480e83..ebef89be 100644 --- a/util/src/entities/ReadState.ts +++ b/util/src/entities/ReadState.ts @@ -32,13 +32,8 @@ export class ReadState extends BaseClass { user: User; @Column({ nullable: true }) - @RelationId((read_state: ReadState) => read_state.last_message) last_message_id: string; - @JoinColumn({ name: "last_message_id" }) - @ManyToOne(() => Message, { nullable: true }) - last_message?: Message; - @Column({ nullable: true }) last_pin_timestamp?: Date; diff --git a/util/src/entities/index.ts b/util/src/entities/index.ts index 7b1c9750..31afed88 100644 --- a/util/src/entities/index.ts +++ b/util/src/entities/index.ts @@ -18,6 +18,7 @@ export * from "./Relationship"; export * from "./Role"; export * from "./Session"; export * from "./Sticker"; +export * from "./StickerPack"; export * from "./Team"; export * from "./TeamMember"; export * from "./Template"; diff --git a/util/src/util/cdn.ts b/util/src/util/cdn.ts index 4dd0078a..ea950cd1 100644 --- a/util/src/util/cdn.ts +++ b/util/src/util/cdn.ts @@ -4,7 +4,9 @@ import fetch from "node-fetch"; import { Config } from "./Config"; import multer from "multer"; -export async function uploadFile(path: string, file: Express.Multer.File) { +export async function uploadFile(path: string, file?: Express.Multer.File) { + if (!file?.buffer) throw new HTTPError("Missing file in body"); + const form = new FormData(); form.append("file", file.buffer, { contentType: file.mimetype, |