1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 04:32:35 +01:00

Merge branch 'master' into feat/refactorIdentify

This commit is contained in:
Madeline 2023-04-01 19:04:22 +11:00
commit 13dedb6d25
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
481 changed files with 9674 additions and 1568 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

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

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,15 +0,0 @@
# Fosscord env vars:
| Name | Value | Description |
| ---------------- | -------------- | --------------------------------------------------------------- |
| THREADS | number | Number of threads to run Fosscord on when using bundle. |
| PORT | number | Port to listen on |
| DATABASE | string | Database connection string. Defaults to SQlite3 at project root |
| CONFIG_PATH | string | File path for JSON config, if not using `config` db table |
| WS_LOGEVENTS | boolean | If set, log websocket events from gateway |
| CDN | string | Lowest priority value for public CDN annoucements |
| GATEWAY | string | Lowest priority value for public gateway annoucements |
| STORAGE_LOCATION | string | CDN storage location. File path or S3 bucktet |
| STORAGE_PROVIDER | "s3" or "file" | CDN storage provider |
| STORAGE_BUCKET | string | S3 bucket name |
| STORAGE_REGION | string | S3 storage region |

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 / {

19
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",
@ -46,6 +46,7 @@
"probe-image-size": "^7.2.3",
"proxy-agent": "^5.0.0",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.5",
"ts-node": "^10.9.1",
"tslib": "^2.4.1",
"typeorm": "^0.3.10",
@ -84,7 +85,7 @@
"nodemailer-mailgun-transport": "^2.1.5",
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport",
"sqlite3": "^5.1.4"
"sqlite3": "^5.1.5"
}
},
"node_modules/@acuminous/bitsyntax": {
@ -7077,9 +7078,9 @@
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="
},
"node_modules/sqlite3": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.4.tgz",
"integrity": "sha512-i0UlWAzPlzX3B5XP2cYuhWQJsTtlMD6obOa1PgeEQ4DHEXUuyJkgv50I3isqZAP5oFc2T8OFvakmDh2W6I+YpA==",
"version": "5.1.5",
"resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.5.tgz",
"integrity": "sha512-7sP16i4wI+yKnGOO2q2ijze7EjQ9US+Vw7DYYwxfFtqNZDGgBcEw0oeDaDvUTq66uJOzVd/z6MkIg+c9erSJKg==",
"hasInstallScript": true,
"optional": true,
"dependencies": {
@ -13560,9 +13561,9 @@
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="
},
"sqlite3": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.4.tgz",
"integrity": "sha512-i0UlWAzPlzX3B5XP2cYuhWQJsTtlMD6obOa1PgeEQ4DHEXUuyJkgv50I3isqZAP5oFc2T8OFvakmDh2W6I+YpA==",
"version": "5.1.5",
"resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.5.tgz",
"integrity": "sha512-7sP16i4wI+yKnGOO2q2ijze7EjQ9US+Vw7DYYwxfFtqNZDGgBcEw0oeDaDvUTq66uJOzVd/z6MkIg+c9erSJKg==",
"optional": true,
"requires": {
"@mapbox/node-pre-gyp": "^1.0.0",

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",
@ -108,16 +108,16 @@
"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",
"nodemailer-mailgun-transport": "^2.1.5",
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport",
"sqlite3": "^5.1.4"
"sqlite3": "^5.1.5"
}
}

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
@ -25,7 +25,7 @@ import {
registerRoutes,
Sentry,
WebAuthn,
} from "@fosscord/util";
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { Server, ServerOptions } from "lambert-server";
import "missing-native-js-functions";
@ -39,21 +39,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 });
@ -126,6 +134,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";
@ -72,14 +72,13 @@ router.post(
"id",
"disabled",
"deleted",
"settings",
"totp_secret",
"mfa_enabled",
"webauthn_enabled",
"security_keys",
"verified",
],
relations: ["security_keys"],
relations: ["security_keys", "settings"],
}).catch(() => {
throw FieldErrors({
login: {
@ -187,7 +186,7 @@ router.post(
// Discord header is just the user id as string, which is not possible with npm-jsonwebtoken package
// https://user-images.githubusercontent.com/6506416/81051916-dd8c9900-8ec2-11ea-8794-daf12d6f31f0.png
res.json({ token, settings: user.settings });
res.json({ token, 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 { 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();
@ -34,7 +34,8 @@ router.post(
where: {
totp_last_ticket: ticket,
},
select: ["id", "totp_secret", "settings"],
select: ["id", "totp_secret"],
relations: ["settings"],
});
const backup = await BackupCode.findOne({
@ -62,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";
@ -54,7 +54,8 @@ router.post(
where: {
totp_last_ticket: ticket,
},
select: ["id", "settings"],
select: ["id"],
relations: ["settings"],
});
const ret = await verifyWebAuthnToken(ticket);

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,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();

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