1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 02:12:40 +01:00

Merge branch 'master' into refactor/dev/connections

This commit is contained in:
Madeline 2023-04-02 10:55:17 +10:00
commit 218f71b82c
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
483 changed files with 9761 additions and 1652 deletions

2
.github/FUNDING.yml vendored
View File

@ -1 +1 @@
open_collective: fosscord
open_collective: spacebar

View File

@ -1,11 +1,11 @@
blank_issues_enabled: true
contact_links:
- name: Fosscord Documentation
url: https://docs.fosscord.com/
about: Need documentation and examples for the Fosscord? Head over to Fosscord's official documentation.
- name: Spacebar Documentation
url: https://docs.spacebar.chat/
about: Need documentation and examples for the Spacebar? Head over to Spacebar's official documentation.
- name: Discord's Developer Documentation
url: https://discord.com/developers/docs/intro
about: Need help with the Discord resources? Head here instead of asking on Fosscord!
- name: Fosscord' Official Discord server
about: Need help with the Discord resources? Head here instead of asking on Spacebar!
- name: Spacebar' Official Discord server
url: https://discord.com/invite/Ms5Ev7S6bF
about: Need help with the server? Talk with us in our official server.

View File

@ -1,28 +1,28 @@
<p align="center">
<img width="100" src="https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Icon-Rounded-Subtract.svg" />
<img width="100" src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/png/Spacebar__Icon-Rounded-Subtract.png" />
</p>
<h1 align="center">Fosscord Server</h1>
<h1 align="center">Spacebar Server</h1>
<p align="center">
<a href="https://discord.gg/ZrnGQP6p3d">
<img src="https://img.shields.io/discord/806142446094385153?color=7489d5&logo=discord&logoColor=ffffff" />
</a>
<img src="https://img.shields.io/static/v1?label=Status&message=Development&color=blue">
<a title="Crowdin" target="_blank" href="https://translate.fosscord.com/"><img src="https://badges.crowdin.net/fosscord/localized.svg"></a>
<a href="https://opencollective.com/fosscord">
<img src="https://opencollective.com/fosscord/tiers/badge.svg">
<a title="Crowdin" target="_blank" href="https://translate.spacebar.chat/"><img src="https://badges.crowdin.net/spacebar/localized.svg"></a>
<a href="https://opencollective.com/spacebar">
<img src="https://opencollective.com/spacebar/tiers/badge.svg">
</a>
</p>
## [About](https://fosscord.com)
## [About](https://spacebar.chat)
This repository contains:
- [Fosscord HTTP API Server](/src/api)
- [Spacebar HTTP API Server](/src/api)
- [WebSocket Gateway Server](/src/gateway)
- [HTTP CDN Server](/src/cdn)
- [Utility and Database Models](/src/util)
## [Contributing](https://docs.fosscord.com/contributing/)
## [Contributing](https://docs.spacebar.chat/contributing/)
## [Setup](https://docs.fosscord.com/setup/server/)
## [Setup](https://docs.spacebar.chat/setup/server/)

View File

@ -24,7 +24,7 @@
<body>
<div style="background-color: #202225;">
<img
src="https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Wordmark-Orange.svg"
src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg"
alt="Branding"
style="
width: 100%;
@ -86,7 +86,7 @@
color: white;
cursor: pointer;
padding: 15px 19px;
background-color: #ff5f00;
background-color: #0185ff;
border-radius: 5px;
"
>Verify Login</a

View File

@ -24,7 +24,7 @@
<body>
<div style="background-color: #202225;">
<img
src="https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Wordmark-Orange.svg"
src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg"
alt="Branding"
style="
width: 100%;

View File

@ -24,7 +24,7 @@
<body>
<div style="background-color: #202225;">
<img
src="https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Wordmark-Orange.svg"
src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg"
alt="Branding"
style="
width: 100%;

View File

@ -24,7 +24,7 @@
<body>
<div style="background-color: #202225;">
<img
src="https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Wordmark-Orange.svg"
src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg"
alt="Branding"
style="
width: 100%;

View File

@ -24,7 +24,7 @@
<body>
<div style="background-color: #202225;">
<img
src="https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Wordmark-Orange.svg"
src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg"
alt="Branding"
style="
width: 100%;

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
}
h3.title-jXR8lp.marginBottom8-AtZOdT.base-1x0h_U.size24-RIRrxO::after {
margin-top: -32px;
content: "Welcome to Fosscord!";
content: "Welcome to Spacebar!";
visibility: visible;
display: block;
}
@ -22,7 +22,7 @@ h3.title-jXR8lp.marginBottom8-AtZOdT.base-1x0h_U.size24-RIRrxO::after {
/* Logo in top left when bg removed */
#app-mount > div.app-1q1i1E > div > a {
/* replace me: original dimensions: 130x36 */
background: url(https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Wordmark-Gradient.svg);
background: url(https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg);
width: 130px;
height: 23px;
background-size: contain;

View File

@ -27,7 +27,7 @@
> foreignObject
> div
> div {
background-image: url(https://raw.githubusercontent.com/fosscord/fosscord/master/assets-rebrand/svg/Fosscord-Icon-Rounded-Subtract.svg);
background-image: url(https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Icon-Rounded-Subtract.svg);
background-size: contain;
border-radius: 50%;
}

65
assets/public/index.html Normal file
View File

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spacebar Server</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Montserrat', sans-serif;
background-color: rgb(10, 10, 10);
color: white;
font-size: 1.1rem;
height: 100vh;
}
* {
padding: 0;
margin: 0;
}
p {
margin-top: 10px;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0 40px 0 40px;
height: 100%;
}
#wordmark {
width: min(500px, 50%);
margin-bottom: 20px;
}
a, a:visited {
color: #0185ff;
}
</style>
</head>
<body>
<div class="container">
<img alt="Spacebar Logo"
id="wordmark"
src="https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg" />
<h1>Welcome!</h1>
<p>If you're viewing this page, that means you've successfully set up your very own Spacebar instance!</p>
<p>For information on how to configure your shiny new setup, you should visit <a href="https://docs.spacebar.chat">our documentation</a></p>
<p>For information on how to connect and use your instance, <a href="https://docs.spacebar.chat/setup/clients">click here</a></p>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
If you want to use it, throw it into the `preload-plugins` folder.
TODO: Make it so this file is not required for webrtc.
Do note that webrtc, as of 17/12/2022, is not implemented yet in fosscord/fosscord-server.
Do note that webrtc, as of 17/12/2022, is not implemented yet in spacebarchat/server.
*/
(this.webpackChunkdiscord_app = this.webpackChunkdiscord_app || []).push([

View File

@ -1,8 +1,8 @@
# This is an example nginx config for Fosscord.
# This is an example nginx config for Spacebar.
server {
# Change server_name
server_name fosscord.example.com;
server_name spacebar.example.com;
listen 80;
location / {

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{
"name": "fosscord-server",
"name": "spacebar-server",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "fosscord-server",
"name": "spacebar-server",
"version": "1.0.0",
"hasInstallScript": true,
"license": "AGPL-3.0-only",

View File

@ -1,7 +1,7 @@
{
"name": "fosscord-server",
"name": "spacebar-server",
"version": "1.0.0",
"description": "A Fosscord server written in Node.js",
"description": "A Spacebar server written in Node.js",
"scripts": {
"prepare": "husky install",
"postinstall": "npx patch-package",
@ -26,17 +26,17 @@
"types": "src/bundle/index.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/fosscord/fosscord-server.git"
"url": "git+https://github.com/spacebarchat/server.git"
},
"author": "Fosscord",
"author": "Spacebar",
"license": "AGPL-3.0-only",
"bugs": {
"url": "https://github.com/fosscord/fosscord-server/issues"
"url": "https://github.com/spacebarchat/server/issues"
},
"imports": {
"#*": "./dist/*/index.js"
},
"homepage": "https://fosscord.com",
"homepage": "https://spacebar.chat",
"devDependencies": {
"@types/amqplib": "^0.8.2",
"@types/bcrypt": "^5.0.0",
@ -109,10 +109,10 @@
"ws": "^8.9.0"
},
"_moduleAliases": {
"@fosscord/api": "dist/api",
"@fosscord/cdn": "dist/cdn",
"@fosscord/gateway": "dist/gateway",
"@fosscord/util": "dist/util"
"@spacebar/api": "dist/api",
"@spacebar/cdn": "dist/cdn",
"@spacebar/gateway": "dist/gateway",
"@spacebar/util": "dist/util"
},
"optionalDependencies": {
"erlpack": "^0.1.4",

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -23,9 +23,11 @@
To find which file the changelog is stored in your client, simply grep for the changelog text given by the client,
and update the `CHANGELOG_SCRIPT` variable to use that instead.
This grabs the new changelog from `fosscord-server/assets/changelog.txt`
This grabs the new changelog from `spacebarchat/server/assets/changelog.txt`
*/
/* eslint-env node */
const fetch = require("node-fetch");
const fs = require("fs/promises");
const path = require("path");

View File

@ -5,13 +5,15 @@
Does not prepend is file contains @fc-license-skip
*/
/* eslint-env node */
const Path = require("path");
const fs = require("fs");
const walk = require("./util/walk");
const FOSSCORD_SOURCE_DIR = Path.join(__dirname, "..", "src");
const FOSSCORD_SCRIPTS_DIR = Path.join(__dirname);
const FOSSCORD_LICENSE_PREAMBLE = fs
const SPACEBAR_SOURCE_DIR = Path.join(__dirname, "..", "src");
const SPACEBAR_SCRIPTS_DIR = Path.join(__dirname);
const SPACEBAR_LICENSE_PREAMBLE = fs
.readFileSync(Path.join(__dirname, "util", "licensePreamble.txt"))
.toString()
.split("\r") // remove windows bs
@ -37,7 +39,7 @@ const addToDir = (dir) => {
const preamble =
commentStrings[0] +
"\n" +
FOSSCORD_LICENSE_PREAMBLE +
SPACEBAR_LICENSE_PREAMBLE +
"\n" +
commentStrings[1];
@ -56,5 +58,5 @@ const addToDir = (dir) => {
}
};
addToDir(FOSSCORD_SOURCE_DIR);
addToDir(FOSSCORD_SCRIPTS_DIR);
addToDir(SPACEBAR_SOURCE_DIR);
addToDir(SPACEBAR_SCRIPTS_DIR);

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* eslint-env node */
require("module-alias/register");
const getRouteDescriptions = require("./util/getRouteDescriptions");
const path = require("path");
@ -27,7 +29,31 @@ require("missing-native-js-functions");
const openapiPath = path.join(__dirname, "..", "assets", "openapi.json");
const SchemaPath = path.join(__dirname, "..", "assets", "schemas.json");
const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
let schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
for (var schema in schemas) {
const part = schemas[schema];
for (var key in part.properties) {
if (part.properties[key].anyOf) {
const nullIndex = part.properties[key].anyOf.findIndex(
(x) => x.type == "null",
);
if (nullIndex != -1) {
part.properties[key].nullable = true;
part.properties[key].anyOf.splice(nullIndex, 1);
if (part.properties[key].anyOf.length == 1) {
Object.assign(
part.properties[key],
part.properties[key].anyOf[0],
);
delete part.properties[key].anyOf;
}
}
}
}
}
const specification = JSON.parse(
fs.readFileSync(openapiPath, { encoding: "utf8" }),
);
@ -109,7 +135,7 @@ function apiRoutes() {
return x.test(path);
})
) {
obj.security = [{ bearer: true }];
obj.security = [{ bearer: [] }];
}
if (route.body) {

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -20,6 +20,8 @@
Calculates a discord.com-like rights value.
*/
/* eslint-env node */
require("module-alias/register");
const { Rights } = require("..");

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,9 +17,11 @@
*/
/*
Regenerates the `fosscord-server/assets/schemas.json` file, used for API/Gateway input validation.
Regenerates the `spacebarchat/server/assets/schemas.json` file, used for API/Gateway input validation.
*/
/* eslint-env node */
const path = require("path");
const fs = require("fs");
const TJS = require("typescript-json-schema");
@ -91,9 +93,9 @@ function main() {
if (!part) continue;
// this is a hack. want some want to check if its a @column, instead
if (part.properties)
Object.keys(part.properties)
.filter((key) =>
if (part.properties) {
for (let key in part.properties) {
if (
[
// BaseClass methods
"toJSON",
@ -104,9 +106,31 @@ function main() {
"recover",
"reload",
"assign",
].includes(key),
)
.forEach((key) => delete part.properties[key]);
].includes(key)
) {
delete part.properties[key];
continue;
}
// if (part.properties[key].anyOf) {
// const nullIndex = part.properties[key].anyOf.findIndex(
// (x) => x.type == "null",
// );
// if (nullIndex != -1) {
// part.properties[key].nullable = true;
// part.properties[key].anyOf.splice(nullIndex, 1);
// if (part.properties[key].anyOf.length == 1) {
// Object.assign(
// part.properties[key],
// part.properties[key].anyOf[0],
// );
// delete part.properties[key].anyOf;
// }
// }
// }
}
}
definitions = { ...definitions, [name]: { ...part } };
}

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,13 +16,15 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* eslint-env node */
const register = require("./src/register");
const login = require("./src/login/index");
const config = require("./config.json");
const figlet = require("figlet");
const sendMessage = require("./src/message/send");
const fs = require("fs");
figlet("Fosscord Stress Test :)", function (err, data) {
figlet("Spacebar Stress Test :)", function (err, data) {
if (err) {
console.log("Something went wrong...");
console.dir(err);

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* eslint-env node */
const fetch = require("node-fetch");
const fs = require("fs");
var config = require("../../config.json");
@ -36,7 +38,7 @@ async function generate() {
var body = {
fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw",
email: mail,
username: "Fosscord Stress Test",
username: "Spacebar Stress Test",
password: password,
invite: config.invite,
consent: true,

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -25,6 +25,8 @@
it doesn't break the below, thus we're left with this :sob:
*/
/* eslint-env node */
require("module-alias/register");
require("dotenv").config();
const { initDatabase } = require("..");

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,5 +1,5 @@
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -27,7 +27,7 @@ import {
WebAuthn,
ConnectionConfig,
ConnectionLoader,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { Server, ServerOptions } from "lambert-server";
import "missing-native-js-functions";
@ -41,21 +41,29 @@ import { initRateLimits } from "./middlewares/RateLimit";
import { initTranslation } from "./middlewares/Translation";
import { initInstance } from "./util/handlers/Instance";
export type FosscordServerOptions = ServerOptions;
const PUBLIC_ASSETS_FOLDER = path.join(
__dirname,
"..",
"..",
"assets",
"public",
);
export type SpacebarServerOptions = ServerOptions;
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Express {
interface Request {
server: FosscordServer;
server: SpacebarServer;
}
}
}
export class FosscordServer extends Server {
public declare options: FosscordServerOptions;
export class SpacebarServer extends Server {
public declare options: SpacebarServerOptions;
constructor(opts?: Partial<FosscordServerOptions>) {
constructor(opts?: Partial<SpacebarServerOptions>) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
super({ ...opts, errorHandler: false, jsonBody: false });
@ -129,6 +137,10 @@ export class FosscordServer extends Server {
app.use("/api/v9", api);
app.use("/api", api); // allow unversioned requests
app.get("/", (req, res) =>
res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")),
);
this.app.use(ErrorHandler);
Sentry.errorHandler(this.app);

4
src/api/global.d.ts vendored
View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { checkToken, Config, Rights } from "@fosscord/util";
import { checkToken, Config, Rights } from "@spacebar/util";
import * as Sentry from "@sentry/node";
import { NextFunction, Request, Response } from "express";
import { HTTPError } from "lambert-server";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -18,7 +18,7 @@
import { NextFunction, Request, Response } from "express";
import { HTTPError } from "lambert-server";
import { ApiError, FieldError } from "@fosscord/util";
import { ApiError, FieldError } from "@spacebar/util";
const EntityNotFoundErrorRegex = /"(\w+)"/;
export function ErrorHandler(

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { getIpAdress } from "@fosscord/api";
import { Config, getRights, listenEvent } from "@fosscord/util";
import { getIpAdress } from "@spacebar/api";
import { Config, getRights, listenEvent } from "@spacebar/util";
import { NextFunction, Request, Response, Router } from "express";
import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
@ -27,7 +27,7 @@ import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
/*
? bucket limit? Max actions/sec per bucket?
(ANSWER: a small fosscord instance might not need a complex rate limiting system)
(ANSWER: a small spacebar instance might not need a complex rate limiting system)
TODO: delay database requests to include multiple queries
TODO: different for methods (GET/POST)
> IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is 10,000 per 10 minutes. An invalid request is one that results in 401, 403, or 429 statuses.

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,8 +17,8 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { getDatabase } from "@fosscord/util";
import { route } from "@spacebar/api";
import { getDatabase } from "@spacebar/util";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,8 +17,8 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { getDatabase } from "@fosscord/util";
import { route } from "@spacebar/api";
import { getDatabase } from "@spacebar/util";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import {
Application,
generateToken,
@ -25,7 +25,7 @@ import {
BotModifySchema,
handleFile,
DiscordApiErrors,
} from "@fosscord/util";
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { verifyToken } from "node-2fa";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,12 +17,12 @@
*/
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import {
Application,
DiscordApiErrors,
ApplicationModifySchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { verifyToken } from "node-2fa";
import { HTTPError } from "lambert-server";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,13 +17,13 @@
*/
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import {
Application,
ApplicationCreateSchema,
trimSpecial,
User,
} from "@fosscord/util";
} from "@spacebar/util";
const router: Router = Router();

View File

@ -1,11 +1,29 @@
import { getIpAdress, route, verifyCaptcha } from "@fosscord/api";
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
import {
Config,
Email,
FieldErrors,
ForgotPasswordSchema,
User,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { route, random } from "@fosscord/api";
import { Config, ValidRegistrationToken } from "@fosscord/util";
import { route, random } from "@spacebar/api";
import { Config, ValidRegistrationToken } from "@spacebar/util";
import { Request, Response, Router } from "express";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,8 +17,8 @@
*/
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { getIpAdress, IPAnalysis } from "@fosscord/api";
import { route } from "@spacebar/api";
import { getIpAdress, IPAnalysis } from "@spacebar/api";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { getIpAdress, route, verifyCaptcha } from "@fosscord/api";
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
import {
adjustEmail,
Config,
@ -26,7 +26,7 @@ import {
LoginSchema,
User,
WebAuthn,
} from "@fosscord/util";
} from "@spacebar/util";
import bcrypt from "bcrypt";
import crypto from "crypto";
import { Request, Response, Router } from "express";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { Request, Response, Router } from "express";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,8 +17,8 @@
*/
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { BackupCode, generateToken, User, TotpSchema } from "@fosscord/util";
import { route } from "@spacebar/api";
import { BackupCode, generateToken, User, TotpSchema } from "@spacebar/util";
import { verifyToken } from "node-2fa";
import { HTTPError } from "lambert-server";
const router = Router();
@ -63,7 +63,7 @@ router.post(
return res.json({
token: await generateToken(user.id),
user_settings: user.settings,
settings: { ...user.settings, index: undefined },
});
},
);

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import {
generateToken,
SecurityKey,
@ -24,7 +24,7 @@ import {
verifyWebAuthnToken,
WebAuthn,
WebAuthnTotpSchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { ExpectedAssertionResult } from "fido2-lib";
import { HTTPError } from "lambert-server";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -26,14 +26,14 @@ import {
adjustEmail,
RegisterSchema,
ValidRegistrationToken,
} from "@fosscord/util";
} from "@spacebar/util";
import {
route,
getIpAdress,
IPAnalysis,
isProxy,
verifyCaptcha,
} from "@fosscord/api";
} from "@spacebar/api";
import bcrypt from "bcrypt";
import { HTTPError } from "lambert-server";
import { MoreThan } from "typeorm";
@ -52,7 +52,7 @@ router.post(
// They're a one time use token that bypasses registration limits ( rates, disabled reg, etc )
let regTokenUsed = false;
if (req.get("Referrer") && req.get("Referrer")?.includes("token=")) {
// eg theyre on https://staging.fosscord.com/register?token=whatever
// eg theyre on https://staging.spacebar.chat/register?token=whatever
const token = req.get("Referrer")?.split("token=")[1].split("&")[0];
if (token) {
const regToken = await ValidRegistrationToken.findOneOrFail({

View File

@ -1,4 +1,22 @@
import { route } from "@fosscord/api";
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { route } from "@spacebar/api";
import {
checkToken,
Config,
@ -7,7 +25,7 @@ import {
generateToken,
PasswordResetSchema,
User,
} from "@fosscord/util";
} from "@spacebar/util";
import bcrypt from "bcrypt";
import { Request, Response, Router } from "express";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,14 +16,14 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { getIpAdress, route, verifyCaptcha } from "@fosscord/api";
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
import {
checkToken,
Config,
FieldErrors,
generateToken,
User,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { route } from "@fosscord/api";
import { Email, User } from "@fosscord/util";
import { route } from "@spacebar/api";
import { Email, User } from "@spacebar/util";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,8 +17,8 @@
*/
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { FieldErrors, User, BackupCodesChallengeSchema } from "@fosscord/util";
import { route } from "@spacebar/api";
import { FieldErrors, User, BackupCodesChallengeSchema } from "@spacebar/util";
import bcrypt from "bcrypt";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -25,9 +25,9 @@ import {
Recipient,
handleFile,
ChannelModifySchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router: Router = Router();
// TODO: delete channel

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -18,8 +18,8 @@
import { Router, Request, Response } from "express";
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
import { random } from "@fosscord/api";
import { route } from "@spacebar/api";
import { random } from "@spacebar/api";
import {
Channel,
Invite,
@ -28,7 +28,7 @@ import {
User,
Guild,
PublicInviteRelation,
} from "@fosscord/util";
} from "@spacebar/util";
import { isTextChannel } from "./messages";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -21,9 +21,9 @@ import {
getPermission,
MessageAckEvent,
ReadState,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -20,7 +20,7 @@ import {
Attachment,
Channel,
emitEvent,
FosscordApiErrors,
SpacebarApiErrors,
getPermission,
getRights,
Message,
@ -31,11 +31,11 @@ import {
uploadFile,
MessageCreateSchema,
MessageEditSchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { Router, Response, Request } from "express";
import multer from "multer";
import { route } from "@fosscord/api";
import { handleMessage, postHandleMessage } from "@fosscord/api";
import { route } from "@spacebar/api";
import { handleMessage, postHandleMessage } from "@spacebar/api";
import { HTTPError } from "lambert-server";
const router = Router();
@ -163,14 +163,14 @@ router.put(
const snowflake = Snowflake.deconstruct(message_id);
if (Date.now() < snowflake.timestamp) {
// message is in the future
throw FosscordApiErrors.CANNOT_BACKFILL_TO_THE_FUTURE;
throw SpacebarApiErrors.CANNOT_BACKFILL_TO_THE_FUTURE;
}
const exists = await Message.findOne({
where: { id: message_id, channel_id: channel_id },
});
if (exists) {
throw FosscordApiErrors.CANNOT_REPLACE_BY_BACKFILL;
throw SpacebarApiErrors.CANNOT_REPLACE_BY_BACKFILL;
}
if (req.file) {

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -30,8 +30,8 @@ import {
PartialEmoji,
PublicUserProjection,
User,
} from "@fosscord/util";
import { route } from "@fosscord/api";
} from "@spacebar/util";
import { route } from "@spacebar/api";
import { Router, Response, Request } from "express";
import { HTTPError } from "lambert-server";
import { In } from "typeorm";

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -25,9 +25,9 @@ import {
getRights,
MessageDeleteBulkEvent,
Message,
} from "@fosscord/util";
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -36,9 +36,9 @@ import {
Rights,
Reaction,
User,
} from "@fosscord/util";
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { handleMessage, postHandleMessage, route } from "@fosscord/api";
import { handleMessage, postHandleMessage, route } from "@spacebar/api";
import multer from "multer";
import { FindManyOptions, FindOperator, LessThan, MoreThan } from "typeorm";
import { URL } from "url";
@ -146,7 +146,7 @@ router.get("/", async (req: Request, res: Response) => {
x.author = User.create({
id: "4",
discriminator: "0000",
username: "Fosscord Ghost",
username: "Spacebar Ghost",
public_flags: 0,
});
x.attachments?.forEach((y: Attachment) => {

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -24,11 +24,11 @@ import {
Member,
Role,
ChannelPermissionOverwriteSchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { Router, Response, Request } from "express";
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router: Router = Router();
// TODO: Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel)

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -24,9 +24,9 @@ import {
Message,
MessageUpdateEvent,
DiscordApiErrors,
} from "@fosscord/util";
} from "@spacebar/util";
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { isTextChannel } from "./messages";
import { FindManyOptions, Between, Not, FindOperator } from "typeorm";
import {
@ -28,7 +28,7 @@ import {
Message,
MessageDeleteBulkEvent,
PurgeSchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { Router, Response, Request } from "express";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -27,8 +27,8 @@ import {
PublicUserProjection,
Recipient,
User,
} from "@fosscord/util";
import { route } from "@fosscord/api";
} from "@spacebar/util";
import { route } from "@spacebar/api";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Channel, emitEvent, Member, TypingStartEvent } from "@fosscord/util";
import { route } from "@fosscord/api";
import { Channel, emitEvent, Member, TypingStartEvent } from "@spacebar/util";
import { route } from "@spacebar/api";
import { Router, Request, Response } from "express";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import {
Channel,
Config,
@ -27,10 +27,10 @@ import {
Webhook,
WebhookCreateSchema,
WebhookType,
} from "@fosscord/util";
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { isTextChannel } from "./messages/index";
import { DiscordApiErrors } from "@fosscord/util";
import { DiscordApiErrors } from "@spacebar/util";
import crypto from "crypto";
const router: Router = Router();
@ -63,7 +63,7 @@ router.post(
// TODO: move this
if (name === "clyde") throw new HTTPError("Invalid name", 400);
if (name === "Fosscord Ghost") throw new HTTPError("Invalid name", 400);
if (name === "Spacebar Ghost") throw new HTTPError("Invalid name", 400);
if (avatar) avatar = await handleFile(`/avatars/${channel_id}`, avatar);

View File

@ -1,4 +1,4 @@
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { Request, Response, Router } from "express";
const router = Router();

View File

@ -1,4 +1,4 @@
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { Request, Response, Router } from "express";
import { ConnectionStore, FieldErrors } from "../../../../util";

View File

@ -1,10 +1,10 @@
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import {
ConnectionCallbackSchema,
ConnectionStore,
emitEvent,
FieldErrors,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,10 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Guild, Config } from "@fosscord/util";
import { Guild, Config } from "@spacebar/util";
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { Like } from "typeorm";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,9 +16,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Categories } from "@fosscord/util";
import { Categories } from "@spacebar/util";
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,8 +17,8 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { FieldErrors, Release } from "@fosscord/util";
import { route } from "@spacebar/api";
import { FieldErrors, Release } from "@spacebar/util";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,23 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Config } from "@fosscord/util";
import { Config } from "@spacebar/util";
import { Router, Response, Request } from "express";
import { route, RouteOptions } from "@fosscord/api";
import { route, RouteOptions } from "@spacebar/api";
const router = Router();
export interface GatewayBotResponse {
url: string;
shards: number;
session_start_limit: {
total: number;
remaining: number;
reset_after: number;
max_concurrency: number;
};
}
const options: RouteOptions = {
test: {
response: {

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,16 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Config } from "@fosscord/util";
import { Config } from "@spacebar/util";
import { Router, Response, Request } from "express";
import { route, RouteOptions } from "@fosscord/api";
import { route, RouteOptions } from "@spacebar/api";
const router = Router();
export interface GatewayResponse {
url: string;
}
const options: RouteOptions = {
test: {
response: {

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -19,7 +19,7 @@
import { Router, Response, Request } from "express";
import fetch from "node-fetch";
import ProxyAgent from "proxy-agent";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { getGifApiKey, parseGifResult } from "./trending";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -19,7 +19,7 @@
import { Router, Response, Request } from "express";
import fetch from "node-fetch";
import ProxyAgent from "proxy-agent";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { getGifApiKey, parseGifResult } from "./trending";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -19,8 +19,8 @@
import { Router, Response, Request } from "express";
import fetch from "node-fetch";
import ProxyAgent from "proxy-agent";
import { route } from "@fosscord/api";
import { Config } from "@fosscord/util";
import { route } from "@spacebar/api";
import { Config } from "@spacebar/util";
import { HTTPError } from "lambert-server";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -16,10 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Guild, Config } from "@fosscord/util";
import { Guild, Config } from "@spacebar/util";
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
import { Like } from "typeorm";
const router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -17,7 +17,7 @@
*/
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();
//TODO: implement audit logs

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -27,9 +27,9 @@ import {
Member,
BanRegistrySchema,
BanModeratorSchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { getIpAdress, route } from "@fosscord/api";
import { getIpAdress, route } from "@spacebar/api";
const router: Router = Router();

View File

@ -1,6 +1,6 @@
/*
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Fosscord and Fosscord Contributors
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
@ -23,9 +23,9 @@ import {
emitEvent,
ChannelModifySchema,
ChannelReorderSchema,
} from "@fosscord/util";
} from "@spacebar/util";
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
import { route } from "@spacebar/api";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {

Some files were not shown because too many files have changed in this diff Show More