mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-17 10:16:01 +00:00
Split config/response voice regions, remove APIVoiceRegion alias
This commit is contained in:
Binary file not shown.
Binary file not shown.
+1
-1
@@ -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 } };
|
||||
|
||||
@@ -27,7 +27,7 @@ router.get(
|
||||
route({
|
||||
responses: {
|
||||
200: {
|
||||
body: "APIGuildVoiceRegion",
|
||||
body: "VoiceRegionListResponse",
|
||||
},
|
||||
404: {
|
||||
body: "APIErrorResponse",
|
||||
|
||||
@@ -26,7 +26,7 @@ router.get(
|
||||
route({
|
||||
responses: {
|
||||
200: {
|
||||
body: "APIGuildVoiceRegion",
|
||||
body: "VoiceRegionListResponse",
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<
|
||||
|
||||
@@ -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;
|
||||
location?: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
};
|
||||
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[];
|
||||
@@ -18,4 +18,4 @@
|
||||
|
||||
export * from "./VoiceIdentifySchema";
|
||||
export * from "./VoiceVideoSchema";
|
||||
export * from "./Region";
|
||||
export * from "./VoiceRegion";
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user