1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-25 11:43:07 +01:00

This is for later

This commit is contained in:
TheArcaneBrony 2022-08-27 09:47:26 +02:00
parent 688c17b8f5
commit 1435f58d84
No known key found for this signature in database
GPG Key ID: 32FC5AAADAD75A22
7 changed files with 1672 additions and 1275 deletions

30
assets/popout.html Normal file
View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=3.0" name="viewport" />
<title>Discord Popout</title>
<link rel="icon" href="/assets/ec2c34cadd4b5f4594415127380a85e6.ico" />
<script nonce="MTI1LDcwLDIzNSw4MiwxODcsMjM4LDExNCw5">
(window.onload = function () {
null != window.opener &&
window.opener.postMessage({ discordPopoutEvent: { type: "loaded", key: window.windowKey } }, window.origin);
}),
(window.onunload = function () {
null != window.opener &&
window.opener.postMessage({ discordPopoutEvent: { type: "unloaded", key: window.windowKey } }, window.origin);
});
</script>
<style>
body,
html {
overflow: hidden;
}
</style>
</head>
<body>
<div id="app-mount"></div>
</body>
</html>

View File

@ -15,7 +15,10 @@
}
},
"additionalProperties": false,
"required": ["afk", "status"],
"required": [
"afk",
"status"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"BanCreateSchema": {
@ -51,7 +54,12 @@
}
},
"additionalProperties": false,
"required": ["executor_id", "guild_id", "id", "user_id"],
"required": [
"executor_id",
"guild_id",
"id",
"user_id"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"BanRegistrySchema": {
@ -77,7 +85,12 @@
}
},
"additionalProperties": false,
"required": ["executor_id", "guild_id", "id", "user_id"],
"required": [
"executor_id",
"guild_id",
"id",
"user_id"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"BulkDeleteSchema": {
@ -91,89 +104,9 @@
}
},
"additionalProperties": false,
"required": ["messages"],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ts.server.TypingInstallerResponse": {
"type": "object",
"properties": {
"kind": {
"enum": [
"action::invalidate",
"action::packageInstalled",
"action::set",
"event::beginInstallTypes",
"event::endInstallTypes",
"event::initializationFailed",
"event::typesRegistry"
"required": [
"messages"
],
"type": "string"
}
},
"additionalProperties": false,
"required": ["kind"],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ts.server.PackageInstalledResponse": {
"type": "object",
"properties": {
"kind": {
"type": "string",
"enum": ["action::packageInstalled"]
},
"success": {
"type": "boolean"
},
"message": {
"type": "string"
},
"projectName": {
"type": "string"
}
},
"additionalProperties": false,
"required": ["kind", "message", "projectName", "success"],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ts.server.InitializationFailedResponse": {
"type": "object",
"properties": {
"kind": {
"type": "string",
"enum": ["event::initializationFailed"]
},
"message": {
"type": "string"
},
"stack": {
"type": "string"
}
},
"additionalProperties": false,
"required": ["kind", "message"],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ts.server.ProjectResponse": {
"type": "object",
"properties": {
"projectName": {
"type": "string"
},
"kind": {
"enum": [
"action::invalidate",
"action::packageInstalled",
"action::set",
"event::beginInstallTypes",
"event::endInstallTypes",
"event::initializationFailed",
"event::typesRegistry"
],
"type": "string"
}
},
"additionalProperties": false,
"required": ["kind", "projectName"],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ChannelPermissionOverwriteSchema": {
@ -200,7 +133,9 @@
}
},
"additionalProperties": false,
"required": ["id"]
"required": [
"id"
]
},
"$schema": "http://json-schema.org/draft-07/schema#"
},
@ -218,7 +153,9 @@
}
},
"additionalProperties": false,
"required": ["recipients"],
"required": [
"recipients"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"EmojiCreateSchema": {
@ -231,7 +168,10 @@
"type": "string"
},
"require_colons": {
"type": ["null", "boolean"]
"type": [
"null",
"boolean"
]
},
"roles": {
"type": "array",
@ -241,7 +181,9 @@
}
},
"additionalProperties": false,
"required": ["image"],
"required": [
"image"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"EmojiModifySchema": {
@ -271,7 +213,10 @@
"type": "string"
},
"icon": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"channels": {
"type": "array",
@ -290,7 +235,9 @@
}
},
"additionalProperties": false,
"required": ["name"],
"required": [
"name"
],
"definitions": {
"ChannelModifySchema": {
"type": "object",
@ -300,14 +247,39 @@
"type": "string"
},
"type": {
"enum": [0, 1, 10, 11, 12, 13, 14, 15, 2, 255, 3, 33, 34, 35, 4, 5, 6, 64, 7, 8, 9],
"enum": [
0,
1,
10,
11,
12,
13,
14,
15,
2,
255,
3,
33,
34,
35,
4,
5,
6,
64,
7,
8,
9
],
"type": "number"
},
"topic": {
"type": "string"
},
"icon": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"bitrate": {
"type": "integer"
@ -340,7 +312,12 @@
}
},
"additionalProperties": false,
"required": ["allow", "deny", "id", "type"]
"required": [
"allow",
"deny",
"id",
"type"
]
}
},
"parent_id": {
@ -368,7 +345,11 @@
"additionalProperties": false
},
"ChannelPermissionOverwriteType": {
"enum": [0, 1, 2],
"enum": [
0,
1,
2
],
"type": "number"
}
},
@ -381,11 +362,16 @@
"type": "string"
},
"avatar": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
}
},
"additionalProperties": false,
"required": ["name"],
"required": [
"name"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"GuildUpdateSchema": {
@ -395,10 +381,16 @@
"type": "string"
},
"banner": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"splash": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"description": {
"type": "string"
@ -440,7 +432,10 @@
"type": "string"
},
"icon": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"guild_template_code": {
"type": "string"
@ -477,7 +472,11 @@
}
},
"additionalProperties": false,
"required": ["channel_id", "description", "emoji_name"]
"required": [
"channel_id",
"description",
"emoji_name"
]
}
},
"enabled": {
@ -542,7 +541,12 @@
"type": "string"
},
"release_channel": {
"enum": ["canary", "dev", "ptb", "stable"],
"enum": [
"canary",
"dev",
"ptb",
"stable"
],
"type": "string"
},
"client_build_number": {
@ -613,7 +617,10 @@
}
},
"additionalProperties": false,
"required": ["properties", "token"],
"required": [
"properties",
"token"
],
"definitions": {
"ActivitySchema": {
"type": "object",
@ -631,7 +638,10 @@
}
},
"additionalProperties": false,
"required": ["afk", "status"]
"required": [
"afk",
"status"
]
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
@ -693,7 +703,10 @@
}
},
"additionalProperties": false,
"required": ["login", "password"],
"required": [
"login",
"password"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"MemberChangeSchema": {
@ -717,7 +730,9 @@
}
},
"additionalProperties": false,
"required": ["nick"],
"required": [
"nick"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"MessageAcknowledgeSchema": {
@ -803,7 +818,10 @@
}
},
"additionalProperties": false,
"required": ["channel_id", "message_id"]
"required": [
"channel_id",
"message_id"
]
},
"payload_json": {
"type": "string"
@ -835,7 +853,9 @@
}
},
"additionalProperties": false,
"required": ["password"],
"required": [
"password"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ModifyGuildStickerSchema": {
@ -856,7 +876,10 @@
}
},
"additionalProperties": false,
"required": ["name", "tags"],
"required": [
"name",
"tags"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"PruneSchema": {
@ -867,7 +890,9 @@
}
},
"additionalProperties": false,
"required": ["days"],
"required": [
"days"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"PurgeSchema": {
@ -881,7 +906,10 @@
}
},
"additionalProperties": false,
"required": ["after", "before"],
"required": [
"after",
"before"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"RegisterSchema": {
@ -924,7 +952,10 @@
}
},
"additionalProperties": false,
"required": ["consent", "username"],
"required": [
"consent",
"username"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"RelationshipPostSchema": {
@ -938,7 +969,10 @@
}
},
"additionalProperties": false,
"required": ["discriminator", "username"],
"required": [
"discriminator",
"username"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"RelationshipPutSchema": {
@ -993,10 +1027,107 @@
}
},
"additionalProperties": false,
"required": ["id", "position"]
"required": [
"id",
"position"
]
},
"$schema": "http://json-schema.org/draft-07/schema#"
},
"SelectProtocolSchema": {
"type": "object",
"properties": {
"protocol": {
"enum": [
"udp",
"webrtc"
],
"type": "string"
},
"data": {
"anyOf": [
{
"type": "object",
"properties": {
"address": {
"type": "string"
},
"port": {
"type": "integer"
},
"mode": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"address",
"mode",
"port"
]
},
{
"type": "string"
}
]
},
"sdp": {
"type": "string"
},
"codecs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"enum": [
"H264",
"VP8",
"VP9",
"opus"
],
"type": "string"
},
"type": {
"enum": [
"audio",
"video"
],
"type": "string"
},
"priority": {
"type": "integer"
},
"payload_type": {
"type": "integer"
},
"rtx_payload_type": {
"type": [
"null",
"integer"
]
}
},
"additionalProperties": false,
"required": [
"name",
"payload_type",
"priority",
"type"
]
}
},
"rtc_connection_id": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"data",
"protocol"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"TemplateCreateSchema": {
"type": "object",
"properties": {
@ -1008,7 +1139,9 @@
}
},
"additionalProperties": false,
"required": ["name"],
"required": [
"name"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"TemplateModifySchema": {
@ -1022,7 +1155,9 @@
}
},
"additionalProperties": false,
"required": ["name"],
"required": [
"name"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"TotpDisableSchema": {
@ -1033,7 +1168,9 @@
}
},
"additionalProperties": false,
"required": ["code"],
"required": [
"code"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"TotpEnableSchema": {
@ -1050,7 +1187,9 @@
}
},
"additionalProperties": false,
"required": ["password"],
"required": [
"password"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"TotpSchema": {
@ -1063,14 +1202,23 @@
"type": "string"
},
"gift_code_sku_id": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"login_source": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
}
},
"additionalProperties": false,
"required": ["code", "ticket"],
"required": [
"code",
"ticket"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"UserModifySchema": {
@ -1085,7 +1233,10 @@
"type": "string"
},
"avatar": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"bio": {
"maxLength": 1024,
@ -1095,7 +1246,10 @@
"type": "integer"
},
"banner": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"password": {
"type": "string"
@ -1130,6 +1284,57 @@
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"VoiceIdentifySchema": {
"type": "object",
"properties": {
"server_id": {
"type": "string"
},
"user_id": {
"type": "string"
},
"session_id": {
"type": "string"
},
"token": {
"type": "string"
},
"video": {
"type": "boolean"
},
"streams": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"rid": {
"type": "string"
},
"quality": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"quality",
"rid",
"type"
]
}
}
},
"additionalProperties": false,
"required": [
"server_id",
"session_id",
"token",
"user_id"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"VoiceStateUpdateSchema": {
"type": "object",
"properties": {
@ -1157,7 +1362,100 @@
}
},
"additionalProperties": false,
"required": ["channel_id"],
"required": [
"channel_id"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"VoiceVideoSchema": {
"type": "object",
"properties": {
"audio_ssrc": {
"type": "integer"
},
"video_ssrc": {
"type": "integer"
},
"rtx_ssrc": {
"type": "integer"
},
"user_id": {
"type": "string"
},
"streams": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": [
"audio",
"video"
],
"type": "string"
},
"rid": {
"type": "string"
},
"ssrc": {
"type": "integer"
},
"active": {
"type": "boolean"
},
"quality": {
"type": "integer"
},
"rtx_ssrc": {
"type": "integer"
},
"max_bitrate": {
"type": "integer"
},
"max_framerate": {
"type": "integer"
},
"max_resolution": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"width": {
"type": "integer"
},
"height": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"height",
"type",
"width"
]
}
},
"additionalProperties": false,
"required": [
"active",
"max_bitrate",
"max_framerate",
"max_resolution",
"quality",
"rid",
"rtx_ssrc",
"ssrc",
"type"
]
}
}
},
"additionalProperties": false,
"required": [
"audio_ssrc",
"video_ssrc"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"WebhookCreateSchema": {
@ -1172,7 +1470,9 @@
}
},
"additionalProperties": false,
"required": ["name"],
"required": [
"name"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"WidgetModifySchema": {
@ -1186,7 +1486,10 @@
}
},
"additionalProperties": false,
"required": ["channel_id", "enabled"],
"required": [
"channel_id",
"enabled"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ChannelModifySchema": {
@ -1197,14 +1500,39 @@
"type": "string"
},
"type": {
"enum": [0, 1, 10, 11, 12, 13, 14, 15, 2, 255, 3, 33, 34, 35, 4, 5, 6, 64, 7, 8, 9],
"enum": [
0,
1,
10,
11,
12,
13,
14,
15,
2,
255,
3,
33,
34,
35,
4,
5,
6,
64,
7,
8,
9
],
"type": "number"
},
"topic": {
"type": "string"
},
"icon": {
"type": ["null", "string"]
"type": [
"null",
"string"
]
},
"bitrate": {
"type": "integer"
@ -1237,7 +1565,12 @@
}
},
"additionalProperties": false,
"required": ["allow", "deny", "id", "type"]
"required": [
"allow",
"deny",
"id",
"type"
]
}
},
"parent_id": {
@ -1265,7 +1598,11 @@
"additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [0, 1, 2],
"enum": [
0,
1,
2
],
"type": "number"
}
},

View File

@ -16,6 +16,8 @@
"settings": {
"files.exclude": {
"*.ansi": true,
"**/cache": true,
"**/cache_src": true
}
},
"launch": {
@ -28,10 +30,16 @@
"type": "node-terminal"
},
{
"command": "kitty npm run start:bundle:vscode-dbg",
"command": "[ \"$(basename $PWD)\" != \"fosscord-server\" ] && cd ..; node scripts/build_new.js && kitty node --enable-source-maps --inspect dist/start.js",
"name": "Run Fosscord with debugger (kitty)",
"request": "launch",
"type": "node-terminal"
},
{
"command": "[ \"$(basename $PWD)\" != \"fosscord-server\" ] && cd ..; $(ps -o comm= $PPID) assets/cache",
"name": "Open testclient patch workspace",
"request": "launch",
"type": "node-terminal"
}
]
}

View File

@ -82,6 +82,15 @@ export default function TestClient(app: Application) {
res.send(fs.readFileSync(path.join(__dirname, "..", "..", "..", "assets", "developers.html"), { encoding: "utf8" }));
});
app.get("/popout", (_req: Request, res: Response) => {
const { useTestClient } = Config.get().client;
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
res.set("content-type", "text/html");
if (!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
res.send(fs.readFileSync(path.join(__dirname, "..", "..", "..", "assets", "popout.html"), { encoding: "utf8" }));
});
app.get("*", (req: Request, res: Response) => {
const { useTestClient } = Config.get().client;
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);

View File

@ -43,6 +43,7 @@ export async function Message(this: WebSocket, buffer: Buffer) {
const OPCodeHandler = OPCodeHandlers[data.op];
if (!OPCodeHandler) {
console.error("[Gateway] Unkown opcode " + data.op);
if(process.env.WS_VERBOSE_UNKNOWN) console.log(data);
// TODO: if all opcodes are implemented comment this out:
// this.close(CloseCodes.Unknown_opcode);
return;

View File

@ -0,0 +1,9 @@
import { Payload, WebSocket } from "@fosscord/gateway";
import { Send } from "../util/Send";
export async function onVoiceServerPing(this: WebSocket, data: Payload) {
console.log("Got voice server ping: ", data, "Doing a noop!");
// return this.close(CloseCodes.Invalid_session);
}

View File

@ -6,6 +6,7 @@ import { onPresenceUpdate } from "./PresenceUpdate";
import { onRequestGuildMembers } from "./RequestGuildMembers";
import { onResume } from "./Resume";
import { onVoiceStateUpdate } from "./VoiceStateUpdate";
import { onVoiceServerPing } from "./VoiceServerPing";
export type OPCodeHandler = (this: WebSocket, data: Payload) => any;
@ -14,12 +15,14 @@ export default {
2: onIdentify,
3: onPresenceUpdate,
4: onVoiceStateUpdate,
// 5: Voice Server Ping
5: onVoiceServerPing, //Voice Server Ping
6: onResume,
// 7: Reconnect: You should attempt to reconnect and resume immediately.
8: onRequestGuildMembers,
// 9: Invalid Session
// 10: Hello
// 11: Heartbeat ACK
// 13: Dm_update
14: onLazyRequest
};