summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
Diffstat (limited to 'api/src')
-rw-r--r--api/src/routes/channels/#channel_id/messages/#message_id/index.ts3
-rw-r--r--api/src/routes/users/@me/index.ts25
-rw-r--r--api/src/schema/Emoji.ts5
-rw-r--r--api/src/schema/Guild.ts2
-rw-r--r--api/src/schema/Invite.ts18
-rw-r--r--api/src/schema/index.ts11
6 files changed, 26 insertions, 38 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 b9d46c4f..9c631a18 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
@@ -1,7 +1,6 @@ import { Channel, emitEvent, getPermission, MessageDeleteEvent, Message, MessageUpdateEvent } from "@fosscord/util"; import { Router, Response, Request } from "express"; import { MessageCreateSchema } from "../../../../../schema/Message"; - import { check } from "../../../../../util/instanceOf"; import { handleMessage, postHandleMessage } from "../../../../../util/Message"; @@ -32,7 +31,7 @@ router.patch("/", check(MessageCreateSchema), async (req: Request, res: Response }); await Promise.all([ - new_message.save(), + new_message!.save(), await emitEvent({ event: "MESSAGE_UPDATE", channel_id, diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts
index d5a5723c..68649215 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts
@@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { User } from "@fosscord/util"; +import { User, PrivateUserProjection } from "@fosscord/util"; import { UserModifySchema } from "../../../schema/User"; import { check } from "../../../util/instanceOf"; import { handleFile } from "../../../util/cdn"; @@ -7,30 +7,9 @@ import { handleFile } from "../../../util/cdn"; const router: Router = Router(); router.get("/", async (req: Request, res: Response) => { - res.json(await User.getPublicUser(req.user_id)); + res.json(await User.getPublicUser(req.user_id, { select: PrivateUserProjection })); }); -const UserUpdateProjection = [ - "accent_color", - "avatar", - "banner", - "bio", - "bot", - "discriminator", - "email", - "flags", - "id", - "locale", - "mfa_enabled", - "nsfw_alllowed", - "phone", - "public_flags", - "purchased_flags", - // "token", // this isn't saved in the db and needs to be set manually - "username", - "verified" -]; - router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => { const body = req.body as UserModifySchema; diff --git a/api/src/schema/Emoji.ts b/api/src/schema/Emoji.ts
index deaccf5c..0406919c 100644 --- a/api/src/schema/Emoji.ts +++ b/api/src/schema/Emoji.ts
@@ -1,14 +1,13 @@ // https://discord.com/developers/docs/resources/emoji - export const EmojiCreateSchema = { name: String, //name of the emoji image: String, // image data the 128x128 emoji image uri - roles: Array //roles allowed to use this emoji + $roles: Array //roles allowed to use this emoji }; export interface EmojiCreateSchema { name: string; // name of the emoji image: string; // image data the 128x128 emoji image uri - roles: []; //roles allowed to use this emoji + roles?: string[]; //roles allowed to use this emoji } diff --git a/api/src/schema/Guild.ts b/api/src/schema/Guild.ts
index 3e98fe76..0f9fd884 100644 --- a/api/src/schema/Guild.ts +++ b/api/src/schema/Guild.ts
@@ -48,7 +48,7 @@ export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels"> { banner?: string; splash?: string; description?: string; - features?: [string]; + features?: string[]; verification_level?: number; default_message_notifications?: number; system_channel_flags?: number; diff --git a/api/src/schema/Invite.ts b/api/src/schema/Invite.ts
index a22449ba..da6192bc 100644 --- a/api/src/schema/Invite.ts +++ b/api/src/schema/Invite.ts
@@ -10,13 +10,13 @@ export const InviteCreateSchema = { $target_user_type: Number }; export interface InviteCreateSchema { - target_user_id?: String; - target_type?: String; - validate?: String; //? wtf is this - max_age?: Number; - max_uses?: Number; - temporary?: Boolean; - unique?: Boolean; - target_user?: String; - target_user_type?: Number; + target_user_id?: string; + target_type?: string; + validate?: string; //? wtf is this + max_age?: number; + max_uses?: number; + temporary?: boolean; + unique?: boolean; + target_user?: string; + target_user_type?: number; } diff --git a/api/src/schema/index.ts b/api/src/schema/index.ts new file mode 100644
index 00000000..b5f38a2f --- /dev/null +++ b/api/src/schema/index.ts
@@ -0,0 +1,11 @@ +export * from "./Ban"; +export * from "./Channel"; +export * from "./Emoji"; +export * from "./Guild"; +export * from "./Invite"; +export * from "./Member"; +export * from "./Message"; +export * from "./Roles"; +export * from "./Template"; +export * from "./User"; +export * from "./Widget";