mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-16 12:52:43 +00:00
Clean up various other schemas
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -20,7 +20,7 @@ import { Request, Response, Router } from "express";
|
||||
import { route } from "@spacebar/api/util/handlers/route";
|
||||
import { Message } from "@spacebar/database";
|
||||
import { Config } from "@spacebar/util";
|
||||
import { PreloadMessagesRequestSchema, PreloadMessagesResponseSchema } from "@spacebar/schemas";
|
||||
import { PreloadMessagesRequestSchema, PublicMessageArray } from "@spacebar/schemas";
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
|
||||
@@ -30,7 +30,7 @@ router.post(
|
||||
requestBody: "PreloadMessagesRequestSchema",
|
||||
responses: {
|
||||
200: {
|
||||
body: "PreloadMessagesResponse",
|
||||
body: "PublicMessageArray",
|
||||
},
|
||||
400: {
|
||||
body: "APIErrorResponse",
|
||||
@@ -62,7 +62,7 @@ router.post(
|
||||
// https://docs.discord.food/resources/message#preload-messages - reactions are not included in the response
|
||||
x.reactions = undefined;
|
||||
return x;
|
||||
}) as unknown as PreloadMessagesResponseSchema;
|
||||
}) as unknown as PublicMessageArray;
|
||||
|
||||
return res.status(200).send(filteredMessages);
|
||||
},
|
||||
|
||||
@@ -92,24 +92,26 @@ router.post("/", route({}), async (req: Request, res: Response) => {
|
||||
}
|
||||
|
||||
if (body.type === InteractionType.MessageComponent || body.data.type === InteractionType.ModalSubmit) {
|
||||
interactionData.message = await Message.findOneOrFail({
|
||||
where: { id: body.message_id, flags: undefined },
|
||||
relations: {
|
||||
author: true,
|
||||
webhook: true,
|
||||
application: true,
|
||||
mentions: true,
|
||||
mention_roles: true,
|
||||
mention_channels: true,
|
||||
sticker_items: true,
|
||||
attachments: true,
|
||||
thread: {
|
||||
recipients: {
|
||||
user: true,
|
||||
interactionData.message = (
|
||||
await Message.findOneOrFail({
|
||||
where: { id: body.message_id, flags: undefined },
|
||||
relations: {
|
||||
author: true,
|
||||
webhook: true,
|
||||
application: true,
|
||||
mentions: true,
|
||||
mention_roles: true,
|
||||
mention_channels: true,
|
||||
sticker_items: true,
|
||||
attachments: true,
|
||||
thread: {
|
||||
recipients: {
|
||||
user: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
).toJSON();
|
||||
}
|
||||
|
||||
await emitEvent({
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PublicMember, PublicUser, Snowflake, InteractionType } from "@spacebar/schemas";
|
||||
// TODO: remove entity imports
|
||||
import { Channel, Message } from "@spacebar/database";
|
||||
import { PublicMember, PublicUser, Snowflake, InteractionType, PublicMessage, PublicChannel } from "@spacebar/schemas";
|
||||
|
||||
export interface InteractionCreateSchema {
|
||||
version: number; // TODO: types?
|
||||
@@ -30,12 +28,12 @@ export interface InteractionCreateSchema {
|
||||
guild?: InteractionGuild;
|
||||
guild_id?: Snowflake;
|
||||
guild_locale?: string;
|
||||
channel?: Channel;
|
||||
channel?: PublicChannel;
|
||||
channel_id?: Snowflake;
|
||||
member?: PublicMember;
|
||||
user?: PublicUser;
|
||||
locale?: string;
|
||||
message?: Message;
|
||||
message?: PublicMessage;
|
||||
app_permissions: string;
|
||||
entitlements?: object[]; // TODO: types?
|
||||
entitlement_sku_ids?: Snowflake[]; // DEPRECATED
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: remove dependency on entities
|
||||
import { User, Webhook } from "@spacebar/database";
|
||||
import { IntegrationGuild, PartialUser, Snowflake } from "@spacebar/schemas";
|
||||
import { IntegrationGuild, PartialUser, PublicUser, Snowflake } from "@spacebar/schemas";
|
||||
|
||||
export enum WebhookType {
|
||||
Incoming = 1,
|
||||
@@ -27,8 +25,8 @@ export enum WebhookType {
|
||||
}
|
||||
|
||||
export interface WebhookCreateResponse {
|
||||
user: User;
|
||||
hook: Webhook;
|
||||
user: PublicUser;
|
||||
hook: WebhookResponse;
|
||||
}
|
||||
|
||||
export type WebhookArray = WebhookResponse[];
|
||||
|
||||
@@ -163,6 +163,7 @@ export interface MessageSnapshot {
|
||||
};
|
||||
}
|
||||
|
||||
export type PublicMessageArray = PublicMessage[];
|
||||
export interface PublicMessage {
|
||||
id: Snowflake;
|
||||
channel_id: Snowflake;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: remove entity import
|
||||
import { Emoji } from "@spacebar/database";
|
||||
import { EmojiResponse } from "@spacebar/schemas/api/guilds/Emoji";
|
||||
|
||||
export interface EmojiSourceResponse {
|
||||
type: "GUILD" | "APPLICATION";
|
||||
@@ -32,7 +31,7 @@ export interface EmojiGuild {
|
||||
icon?: string | null;
|
||||
description?: string | null;
|
||||
features: string[];
|
||||
emojis: Emoji[];
|
||||
emojis: EmojiResponse[];
|
||||
premium_tier: number;
|
||||
premium_subscription_count?: number;
|
||||
approximate_member_count?: number;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// TODO: remove dependency on entities
|
||||
import { Role } from "@spacebar/database";
|
||||
import { BaseMessageComponents, Embed, MessageType, Poll, PublicUser } from "@spacebar/schemas";
|
||||
import { BaseMessageComponents, Embed, MessageType, Poll, PublicUser, RoleResponse } from "@spacebar/schemas";
|
||||
import { PublicAttachment } from "../api/messages/Attachments";
|
||||
|
||||
export interface GuildMessagesSearchMessage {
|
||||
@@ -30,7 +30,7 @@ export interface GuildMessagesSearchMessage {
|
||||
attachments: PublicAttachment[];
|
||||
embeds: Embed[];
|
||||
mentions: PublicUser[];
|
||||
mention_roles: Role[];
|
||||
mention_roles: RoleResponse[];
|
||||
pinned: boolean;
|
||||
mention_everyone?: boolean;
|
||||
tts: boolean;
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: remove entity imports
|
||||
import { Emoji, Role, Sticker } from "@spacebar/database";
|
||||
import { GuildCreateResponse } from "@spacebar/schemas";
|
||||
import { GuildCreateResponse, RoleResponse, StickerResponse } from "@spacebar/schemas";
|
||||
import { EmojiResponse } from "@spacebar/schemas/api/guilds/Emoji";
|
||||
|
||||
export interface MemberJoinGuildResponse {
|
||||
guild: GuildCreateResponse;
|
||||
emojis: Emoji[];
|
||||
roles: Role[];
|
||||
stickers: Sticker[];
|
||||
emojis: EmojiResponse[];
|
||||
roles: RoleResponse[];
|
||||
stickers: StickerResponse[];
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: remove entity import
|
||||
import { Message } from "@spacebar/database";
|
||||
import { PublicMessage } from "@spacebar/schemas";
|
||||
|
||||
export type PreloadMessagesResponseSchema = Message[];
|
||||
export type PreloadMessagesResponseSchema = PublicMessage[];
|
||||
|
||||
Reference in New Issue
Block a user