diff --git a/assets/openapi.json b/assets/openapi.json index 1927df6dc..1f5648c86 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index 4ae18b580..82540d363 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ diff --git a/src/database/entities/Message.ts b/src/database/entities/Message.ts index c3ab8c190..629e68741 100644 --- a/src/database/entities/Message.ts +++ b/src/database/entities/Message.ts @@ -341,7 +341,7 @@ export class Message extends BaseClass { nonce: this.nonce ?? undefined, tts: this.tts ?? false, guild: this.guild ?? undefined, - webhook: this.webhook ?? undefined, + webhook: this.webhook?.toMessageWebhook() ?? undefined, interaction: this.interaction ?? undefined, interaction_metadata: this.interaction_metadata ?? undefined, reactions: this.reactions ?? undefined, @@ -362,7 +362,7 @@ export class Message extends BaseClass { pinned: this.pinned, thread: this.thread ? this.thread.toJSON() : this.thread, referenced_message: this.referenced_message && !shallow ? this.referenced_message.toJSON(true) : undefined, - }; + } satisfies PublicMessage; } toPartialMessage(): PartialMessage { diff --git a/src/database/entities/Webhook.ts b/src/database/entities/Webhook.ts index 26cf18aa8..5ba2a8fbb 100644 --- a/src/database/entities/Webhook.ts +++ b/src/database/entities/Webhook.ts @@ -22,7 +22,7 @@ import { BaseClass } from "./BaseClass"; import { Channel } from "./Channel"; import { Guild } from "./Guild"; import { User } from "./User"; -import { WebhookType } from "@spacebar/schemas"; +import { PublicMessageWebhook, WebhookType } from "@spacebar/schemas"; @Entity({ name: "webhooks", @@ -101,4 +101,16 @@ export class Webhook extends BaseClass { source_channel: Channel; url: string; + + public toMessageWebhook(): PublicMessageWebhook { + return { + type: this.type, + name: this.name, + avatar: this.avatar, + user_id: this.user_id, + application_id: this.application_id, + source_guild_id: this.source_guild_id, + source_channel_id: this.source_channel_id, + }; + } } diff --git a/src/schemas/api/messages/Message.ts b/src/schemas/api/messages/Message.ts index eed8d2ad2..8d736aa68 100644 --- a/src/schemas/api/messages/Message.ts +++ b/src/schemas/api/messages/Message.ts @@ -18,7 +18,7 @@ // TODO: remove entity import import { Sticker } from "@spacebar/database"; -import { Embed, MessageActivity, MessageComponent, PartialUser, Poll, PublicChannel, Snowflake } from "@spacebar/schemas"; +import { Embed, MessageActivity, MessageComponent, PartialUser, Poll, PublicChannel, Snowflake, WebhookType } from "@spacebar/schemas"; import { PublicAttachment } from "./Attachments"; export enum MessageType { @@ -207,6 +207,18 @@ export interface PublicMessage { // soundboard_sounds?: SoundboardSound[]; potions?: Potion[]; shared_client_theme?: SharedClientTheme; + // spacebar extension + webhook: PublicMessageWebhook; +} + +export interface PublicMessageWebhook { + type: WebhookType; + name: string; + avatar: string; + user_id: string; + application_id: string; + source_guild_id: string | undefined; + source_channel_id: string; } export interface SharedClientTheme {