summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-04-18 01:24:35 +0200
committerRory& <root@rory.gay>2026-04-18 18:26:34 +0200
commit74b6c03c52660bf3a39602050f4ce44ddb73c6ea (patch)
treede4b1f10283334fc58c4038407fcac9a69cc449b
parentRemove irrelevant TODO (diff)
downloadserver-ts-74b6c03c52660bf3a39602050f4ce44ddb73c6ea.tar.xz
Attachment -> PublicAttachment in schemas
-rw-r--r--assets/openapi.json248
-rw-r--r--assets/schemas.json166
-rw-r--r--src/schemas/api/messages/Message.ts4
-rw-r--r--src/schemas/responses/AccountStandingResponse.ts5
-rw-r--r--src/schemas/responses/GuildMessagesSearchResponse.ts5
-rw-r--r--src/util/entities/Message.ts2
6 files changed, 328 insertions, 102 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index 25833b97..30460482 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -2006,6 +2006,97 @@ "valid_rules_channel" ] }, + "MessageSnapshot": { + "type": "object", + "properties": { + "message": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "edited_timestamp": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ] + }, + "mentions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PartialUser" + } + }, + "mention_roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PublicAttachment" + } + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Embed" + } + }, + "type": { + "$ref": "#/components/schemas/MessageType" + }, + "flags": { + "type": "integer" + }, + "components": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MessageComponent" + } + }, + "resolved": { + "type": "array", + "items": { + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "sticker_items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Sticker" + } + } + }, + "additionalProperties": false, + "required": [ + "content", + "embeds", + "flags", + "mention_roles", + "mentions", + "timestamp", + "type" + ] + } + }, + "required": [ + "message" + ] + }, "GuildMessagesSearchResponse": { "type": "object", "properties": { @@ -12300,97 +12391,6 @@ "me_voted" ] }, - "MessageSnapshot": { - "type": "object", - "properties": { - "message": { - "type": "object", - "properties": { - "content": { - "type": "string" - }, - "timestamp": { - "type": "string", - "format": "date-time" - }, - "edited_timestamp": { - "anyOf": [ - { - "type": "string", - "format": "date-time" - }, - { - "type": "null" - } - ] - }, - "mentions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PartialUser" - } - }, - "mention_roles": { - "type": "array", - "items": { - "type": "string" - } - }, - "attachments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Attachment" - } - }, - "embeds": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Embed" - } - }, - "type": { - "$ref": "#/components/schemas/MessageType" - }, - "flags": { - "type": "integer" - }, - "components": { - "type": "array", - "items": { - "$ref": "#/components/schemas/MessageComponent" - } - }, - "resolved": { - "type": "array", - "items": { - "type": "object", - "properties": {}, - "additionalProperties": true - } - }, - "sticker_items": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Sticker" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "embeds", - "flags", - "mention_roles", - "mentions", - "timestamp", - "type" - ] - } - }, - "required": [ - "message" - ] - }, "PartialUser": { "type": "object", "properties": { @@ -12477,6 +12477,38 @@ "username" ] }, + "PublicAttachment": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ] + }, "MessageComponent": { "type": "object", "properties": { @@ -13073,7 +13105,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/Attachment" + "$ref": "#/components/schemas/PublicAttachment" } }, "embeds": { @@ -13223,6 +13255,38 @@ "username" ] }, + "PublicAttachment_1": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ] + }, "GuildVanityUrl": { "type": "object", "properties": { diff --git a/assets/schemas.json b/assets/schemas.json
index a7acf2b0..2cf6a939 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -2148,6 +2148,100 @@ "messages", "total_results" ], + "definitions": { + "MessageSnapshot": { + "type": "object", + "properties": { + "message": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "edited_timestamp": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ] + }, + "mentions": { + "type": "array", + "items": { + "$ref": "#/definitions/PartialUser" + } + }, + "mention_roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicAttachment_1" + } + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/definitions/Embed" + } + }, + "type": { + "$ref": "#/definitions/MessageType" + }, + "flags": { + "type": "integer" + }, + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/MessageComponent" + } + }, + "resolved": { + "type": "array", + "items": { + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "sticker_items": { + "type": "array", + "items": { + "$ref": "#/definitions/Sticker" + } + } + }, + "additionalProperties": false, + "required": [ + "content", + "embeds", + "flags", + "mention_roles", + "mentions", + "timestamp", + "type" + ] + } + }, + "additionalProperties": false, + "required": [ + "message" + ] + } + }, "$schema": "http://json-schema.org/draft-07/schema#" }, "GuildPruneResponse": { @@ -13093,7 +13187,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/Attachment" + "$ref": "#/definitions/PublicAttachment" } }, "embeds": { @@ -13243,6 +13337,40 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, + "PublicAttachment": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, "MessageComponent": { "type": "object", "properties": { @@ -13872,7 +14000,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/Attachment" + "$ref": "#/definitions/PublicAttachment" } }, "embeds": { @@ -14028,6 +14156,40 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, + "PublicAttachment_1": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, "GuildVanityUrl": { "type": "object", "properties": { diff --git a/src/schemas/api/messages/Message.ts b/src/schemas/api/messages/Message.ts
index ee2b9a8b..f99f2b1b 100644 --- a/src/schemas/api/messages/Message.ts +++ b/src/schemas/api/messages/Message.ts
@@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { Attachment, Sticker } from "@spacebar/util"; +import { Sticker } from "@spacebar/util"; import { Embed, MessageActivity, MessageComponent, PartialUser, Poll, PublicChannel, Snowflake } from "@spacebar/schemas"; import { PublicAttachment } from "./Attachments"; @@ -151,7 +151,7 @@ export interface MessageSnapshot { edited_timestamp?: Date | null; mentions: PartialUser[]; mention_roles: Snowflake[]; - attachments?: Attachment[]; + attachments?: PublicAttachment[]; embeds: Embed[]; type: MessageType; flags: number; diff --git a/src/schemas/responses/AccountStandingResponse.ts b/src/schemas/responses/AccountStandingResponse.ts
index 6f29ebef..c1f603bd 100644 --- a/src/schemas/responses/AccountStandingResponse.ts +++ b/src/schemas/responses/AccountStandingResponse.ts
@@ -16,8 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -// TODO: remove dependency on entities... -import { Attachment } from "@spacebar/util"; +import { PublicAttachment } from "../api/messages/Attachments"; export enum AccountStandingState { ALL_GOOD = 100, @@ -114,7 +113,7 @@ export interface FlaggedContent { type: "message"; id: string; content: string; - attachments: Attachment[]; + attachments: PublicAttachment[]; } export interface Classification { diff --git a/src/schemas/responses/GuildMessagesSearchResponse.ts b/src/schemas/responses/GuildMessagesSearchResponse.ts
index 8627b3fc..e498f8bc 100644 --- a/src/schemas/responses/GuildMessagesSearchResponse.ts +++ b/src/schemas/responses/GuildMessagesSearchResponse.ts
@@ -17,8 +17,9 @@ */ // TODO: remove dependency on entities -import { Attachment, Role } from "@spacebar/util"; +import { Role } from "@spacebar/util"; import { BaseMessageComponents, Embed, MessageType, Poll, PublicUser } from "@spacebar/schemas"; +import { PublicAttachment } from "../api/messages/Attachments"; export interface GuildMessagesSearchMessage { id: string; @@ -26,7 +27,7 @@ export interface GuildMessagesSearchMessage { content?: string; channel_id: string; author: PublicUser; - attachments: Attachment[]; + attachments: PublicAttachment[]; embeds: Embed[]; mentions: PublicUser[]; mention_roles: Role[]; diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts
index 217f1da0..c2628e2c 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts
@@ -331,7 +331,7 @@ export class Message extends BaseClass { toSnapshot(): MessageSnapshot { return { message: { - attachments: this.attachments, + attachments: this.attachments?.map((x) => x.toJSON()), components: this.components, content: this.content!, edited_timestamp: this.edited_timestamp,