summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-13 01:57:19 +0200
committerRory& <root@rory.gay>2026-06-13 01:57:19 +0200
commit6995aa7f74e78be9cff90fde3d1c913bce834aac (patch)
treefbed51519ee03b5715d4ba1bb97bb614d7b3719b
parentBump discord-protos (diff)
downloadserver-ts-6995aa7f74e78be9cff90fde3d1c913bce834aac.tar.xz
Split config/response voice regions, remove APIVoiceRegion alias
-rw-r--r--assets/openapi.json110
-rw-r--r--assets/schemas.json116
-rw-r--r--scripts/schema.js2
-rw-r--r--src/api/routes/guilds/#guild_id/regions.ts2
-rw-r--r--src/api/routes/voice/regions.ts2
-rw-r--r--src/gateway/opcodes/VoiceStateUpdate.ts4
-rw-r--r--src/schemas/responses/TypedResponses.ts1
-rw-r--r--src/schemas/webrtc/VoiceRegion.ts (renamed from src/schemas/webrtc/Region.ts)18
-rw-r--r--src/schemas/webrtc/index.ts2
-rw-r--r--src/util/config/types/RegionConfiguration.ts4
10 files changed, 140 insertions, 121 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index 1d1e8dfa..95a8807f 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -205,21 +205,6 @@ "type" ] }, - "RouteResponse": { - "type": "object", - "properties": { - "status": { - "type": "integer" - }, - "body": { - "type": "string", - "pattern": "^.*Response$" - }, - "headers": { - "$ref": "#/components/schemas/Record%3Cstring%2Cstring%3E" - } - } - }, "FieldErrorResponse": { "type": "object", "properties": { @@ -239,6 +224,21 @@ "message" ] }, + "RouteResponse": { + "type": "object", + "properties": { + "status": { + "type": "integer" + }, + "body": { + "type": "string", + "pattern": "^.*Response$" + }, + "headers": { + "$ref": "#/components/schemas/Record%3Cstring%2Cstring%3E" + } + } + }, "ActivitySchema": { "type": "object", "properties": { @@ -4156,6 +4156,43 @@ "video_ssrc" ] }, + "VoiceRegionResponse": { + "type": "object", + "properties": { + "optimal": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "vip": { + "type": "boolean" + }, + "custom": { + "type": "boolean" + }, + "deprecated": { + "type": "boolean" + } + }, + "required": [ + "custom", + "deprecated", + "id", + "name", + "optimal", + "vip" + ] + }, + "VoiceRegionListResponse": { + "type": "array", + "items": { + "$ref": "#/components/schemas/VoiceRegionResponse" + } + }, "APIGuild": { "type": "object", "properties": { @@ -5072,12 +5109,6 @@ "$ref": "#/components/schemas/Template" } }, - "APIGuildVoiceRegion": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GuildVoiceRegion" - } - }, "APILimitsConfiguration": { "type": "object", "properties": { @@ -5850,6 +5881,9 @@ "MessageEditSchema": { "type": "object", "properties": { + "poll": { + "$ref": "#/components/schemas/PollCreationSchema" + }, "embed": { "anyOf": [ { @@ -6003,9 +6037,6 @@ } ] }, - "poll": { - "$ref": "#/components/schemas/PollCreationSchema" - }, "enforce_nonce": { "type": "boolean" }, @@ -14141,33 +14172,6 @@ "name" ] }, - "GuildVoiceRegion": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "custom": { - "type": "boolean" - }, - "deprecated": { - "type": "boolean" - }, - "optimal": { - "type": "boolean" - } - }, - "required": [ - "custom", - "deprecated", - "id", - "name", - "optimal" - ] - }, "UserLimits": { "type": "object", "properties": { @@ -15176,7 +15180,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/APIGuildVoiceRegion" + "$ref": "#/components/schemas/VoiceRegionListResponse" } } } @@ -21165,7 +21169,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/APIGuildVoiceRegion" + "$ref": "#/components/schemas/VoiceRegionListResponse" } } } diff --git a/assets/schemas.json b/assets/schemas.json
index 426a8776..9506fab1 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -186,23 +186,6 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "RouteResponse": { - "type": "object", - "properties": { - "status": { - "type": "integer" - }, - "body": { - "type": "string", - "pattern": "^.*Response$" - }, - "headers": { - "$ref": "#/definitions/Record%3Cstring%2Cstring%3E" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, "FieldErrorResponse": { "type": "object", "properties": { @@ -224,6 +207,23 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, + "RouteResponse": { + "type": "object", + "properties": { + "status": { + "type": "integer" + }, + "body": { + "type": "string", + "pattern": "^.*Response$" + }, + "headers": { + "$ref": "#/definitions/Record%3Cstring%2Cstring%3E" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/draft-07/schema#" + }, "ActivitySchema": { "type": "object", "properties": { @@ -4398,6 +4398,46 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, + "VoiceRegionResponse": { + "type": "object", + "properties": { + "optimal": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "vip": { + "type": "boolean" + }, + "custom": { + "type": "boolean" + }, + "deprecated": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "custom", + "deprecated", + "id", + "name", + "optimal", + "vip" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "VoiceRegionListResponse": { + "type": "array", + "items": { + "$ref": "#/definitions/VoiceRegionResponse" + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, "APIGuild": { "type": "object", "properties": { @@ -5373,13 +5413,6 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "APIGuildVoiceRegion": { - "type": "array", - "items": { - "$ref": "#/definitions/GuildVoiceRegion" - }, - "$schema": "http://json-schema.org/draft-07/schema#" - }, "APILimitsConfiguration": { "type": "object", "properties": { @@ -6208,6 +6241,9 @@ "MessageEditSchema": { "type": "object", "properties": { + "poll": { + "$ref": "#/definitions/PollCreationSchema" + }, "embed": { "anyOf": [ { @@ -6361,9 +6397,6 @@ } ] }, - "poll": { - "$ref": "#/definitions/PollCreationSchema" - }, "enforce_nonce": { "type": "boolean" }, @@ -15118,35 +15151,6 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "GuildVoiceRegion": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "custom": { - "type": "boolean" - }, - "deprecated": { - "type": "boolean" - }, - "optimal": { - "type": "boolean" - } - }, - "additionalProperties": false, - "required": [ - "custom", - "deprecated", - "id", - "name", - "optimal" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, "UserLimits": { "type": "object", "properties": { diff --git a/scripts/schema.js b/scripts/schema.js
index 54d9335d..36949830 100644 --- a/scripts/schema.js +++ b/scripts/schema.js
@@ -256,7 +256,7 @@ async function main() { process.stdout.write( "Done in " + yellowBright(elapsed.totalMilliseconds + "." + elapsed.microseconds) + " ms, " + yellowBright(JSON.stringify(part).length) + " bytes (unformatted) ", ); - if (elapsed.totalMilliseconds >= 20) console.log(bgRedBright("\x1b[5m[SLOW]\x1b[25m")); + if (elapsed.totalMilliseconds >= 100) console.log(bgRedBright("\x1b[5m[SLOW]\x1b[25m")); else console.log(); definitions = { ...definitions, [name]: { ...part } }; diff --git a/src/api/routes/guilds/#guild_id/regions.ts b/src/api/routes/guilds/#guild_id/regions.ts
index 4edf582c..12fb33df 100644 --- a/src/api/routes/guilds/#guild_id/regions.ts +++ b/src/api/routes/guilds/#guild_id/regions.ts
@@ -27,7 +27,7 @@ router.get( route({ responses: { 200: { - body: "APIGuildVoiceRegion", + body: "VoiceRegionListResponse", }, 404: { body: "APIErrorResponse", diff --git a/src/api/routes/voice/regions.ts b/src/api/routes/voice/regions.ts
index a6759b55..d23a0cb7 100644 --- a/src/api/routes/voice/regions.ts +++ b/src/api/routes/voice/regions.ts
@@ -26,7 +26,7 @@ router.get( route({ responses: { 200: { - body: "APIGuildVoiceRegion", + body: "VoiceRegionListResponse", }, }, }), diff --git a/src/gateway/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts
index e6975358..bcde7ed6 100644 --- a/src/gateway/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts
@@ -19,7 +19,7 @@ import { Guild, Member, VoiceState } from "@spacebar/database"; import { Payload, WebSocket, genVoiceToken } from "@spacebar/gateway"; import { Config, emitEvent, VoiceServerUpdateEvent, VoiceStateUpdateEvent } from "@spacebar/util"; -import { Region, VoiceStateUpdateSchema } from "@spacebar/schemas"; +import { ConfigVoiceRegion, VoiceStateUpdateSchema } from "@spacebar/schemas"; import { check } from "./instanceOf"; // TODO: check if a voice server is setup @@ -127,7 +127,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { where: { id: voiceState.guild_id }, }); const regions = Config.get().regions; - let guildRegion: Region | undefined; + let guildRegion: ConfigVoiceRegion | undefined; const defaultRegion = regions.available.find((r) => r.id === regions.default); diff --git a/src/schemas/responses/TypedResponses.ts b/src/schemas/responses/TypedResponses.ts
index 9b7d64ee..692487b0 100644 --- a/src/schemas/responses/TypedResponses.ts +++ b/src/schemas/responses/TypedResponses.ts
@@ -56,7 +56,6 @@ export interface APIGuildWithJoinedAt extends GuildCreateResponse { export type APIRoleArray = Role[]; export type APITemplateArray = Template[]; -export type APIGuildVoiceRegion = GuildVoiceRegion[]; export type APILimitsConfiguration = LimitsConfiguration; export type APIConnectionsConfiguration = Record< diff --git a/src/schemas/webrtc/Region.ts b/src/schemas/webrtc/VoiceRegion.ts
index 57f1602e..0f98a30c 100644 --- a/src/schemas/webrtc/Region.ts +++ b/src/schemas/webrtc/VoiceRegion.ts
@@ -16,15 +16,27 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -export interface Region { +export interface BaseVoiceRegion { id: string; name: string; - endpoint: string; + vip: boolean; + custom: boolean; + deprecated: boolean; +} + +export interface ConfigVoiceRegion extends BaseVoiceRegion { + endpoint: string; // not spec, used for config location?: { latitude: number; longitude: number; - }; + }; // not spec, used for config vip: boolean; custom: boolean; deprecated: boolean; } + +export interface VoiceRegionResponse extends BaseVoiceRegion { + optimal: boolean; +} + +export type VoiceRegionListResponse = VoiceRegionResponse[]; diff --git a/src/schemas/webrtc/index.ts b/src/schemas/webrtc/index.ts
index b4c023a4..a9e47e6b 100644 --- a/src/schemas/webrtc/index.ts +++ b/src/schemas/webrtc/index.ts
@@ -18,4 +18,4 @@ export * from "./VoiceIdentifySchema"; export * from "./VoiceVideoSchema"; -export * from "./Region"; +export * from "./VoiceRegion"; diff --git a/src/util/config/types/RegionConfiguration.ts b/src/util/config/types/RegionConfiguration.ts
index bf953688..1cac1104 100644 --- a/src/util/config/types/RegionConfiguration.ts +++ b/src/util/config/types/RegionConfiguration.ts
@@ -16,12 +16,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { Region } from "@spacebar/schemas"; +import { ConfigVoiceRegion } from "@spacebar/schemas"; export class RegionConfiguration { default: string = "spacebar"; useDefaultAsOptimal: boolean = true; - available: Region[] = [ + available: ConfigVoiceRegion[] = [ { id: "spacebar", name: "spacebar",