mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 02:12:40 +01:00
Merge branch 'spacebarchat:master' into fix/extended-settings-schema
This commit is contained in:
commit
0b9680bc57
@ -1857,6 +1857,9 @@
|
||||
"version"
|
||||
]
|
||||
},
|
||||
"client_status": {
|
||||
"$ref": "#/components/schemas/ClientStatus"
|
||||
},
|
||||
"status": {
|
||||
"$ref": "#/components/schemas/Status"
|
||||
},
|
||||
@ -1867,6 +1870,7 @@
|
||||
"required": [
|
||||
"activities",
|
||||
"client_info",
|
||||
"client_status",
|
||||
"id",
|
||||
"session_id",
|
||||
"status",
|
||||
@ -1874,6 +1878,23 @@
|
||||
"user_id"
|
||||
]
|
||||
},
|
||||
"ClientStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"desktop": {
|
||||
"type": "string"
|
||||
},
|
||||
"mobile": {
|
||||
"type": "string"
|
||||
},
|
||||
"web": {
|
||||
"type": "string"
|
||||
},
|
||||
"embedded": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Relationship": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -3867,20 +3888,6 @@
|
||||
"code"
|
||||
]
|
||||
},
|
||||
"ClientStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"desktop": {
|
||||
"type": "string"
|
||||
},
|
||||
"mobile": {
|
||||
"type": "string"
|
||||
},
|
||||
"web": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Snowflake": {
|
||||
"description": "A container for useful snowflake-related methods.",
|
||||
"type": "object"
|
||||
@ -4310,6 +4317,9 @@
|
||||
},
|
||||
"is_primary": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@ -4360,9 +4370,14 @@
|
||||
"maxFriends": {
|
||||
"type": "integer",
|
||||
"default": 5000
|
||||
},
|
||||
"maxBio": {
|
||||
"type": "integer",
|
||||
"default": 190
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"maxBio",
|
||||
"maxFriends",
|
||||
"maxGuilds",
|
||||
"maxUsername"
|
||||
@ -6243,6 +6258,42 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"RequestGuildMembersSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"guild_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"query": {
|
||||
"type": "string"
|
||||
},
|
||||
"limit": {
|
||||
"type": "integer"
|
||||
},
|
||||
"presences": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"user_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"nonce": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"guild_id"
|
||||
]
|
||||
},
|
||||
"RoleModifySchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -6544,7 +6595,6 @@
|
||||
"nullable": true
|
||||
},
|
||||
"bio": {
|
||||
"maxLength": 1024,
|
||||
"type": "string"
|
||||
},
|
||||
"accent_color": {
|
||||
|
11255
assets/schemas.json
11255
assets/schemas.json
File diff suppressed because it is too large
Load Diff
118
flake.lock
118
flake.lock
@ -1,61 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1708118438,
|
||||
"narHash": "sha256-kk9/0nuVgA220FcqH/D2xaN6uGyHp/zoxPNUmPCMmEE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5863c27340ba4de8f83e7e3c023b9599c3cb3c80",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1723362943,
|
||||
"narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a58bc8ad779655e790115244571758e8de055e3d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"npmDepsHash": "sha256-fZNDN2/fNy6Nu7tbr0RhQ8j4BP7X1Yhrh/fSTH7hbJc="
|
||||
}
|
||||
"npmDepsHash": "sha256-kdS1SwcBu6Dor92iO1ickLgz0T5UL16nyA49xXGajf4="
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
nix flake update
|
||||
DEPS_HASH=`prefetch-npm-deps package-lock.json`
|
||||
TMPFILE=$(mktemp)
|
||||
jq '.npm_deps_hash = "'$DEPS_HASH'"' hashes.json > $TMPFILE
|
||||
jq '.npmDepsHash = "'$DEPS_HASH'"' hashes.json > $TMPFILE
|
||||
mv -- "$TMPFILE" hashes.json
|
||||
|
||||
nom build .# || exit $?
|
||||
|
2036
package-lock.json
generated
2036
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -59,14 +59,14 @@
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"eslint": "^8.56.0",
|
||||
"express": "^4.18.2",
|
||||
"express": "^4.19.2",
|
||||
"husky": "^8.0.3",
|
||||
"prettier": "^2.8.8",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.385.0",
|
||||
"@aws-sdk/client-s3": "^3.629.0",
|
||||
"@sentry/integrations": "^7.66.0",
|
||||
"@sentry/node": "^7.66.0",
|
||||
"ajv": "8.6.2",
|
||||
@ -97,7 +97,7 @@
|
||||
"node-2fa": "^2.0.3",
|
||||
"node-fetch": "^2.6.12",
|
||||
"node-os-utils": "^1.3.7",
|
||||
"nodemailer": "^6.9.4",
|
||||
"nodemailer": "^6.9.14",
|
||||
"picocolors": "^1.0.0",
|
||||
"probe-image-size": "^7.2.3",
|
||||
"proxy-agent": "^6.3.0",
|
||||
@ -107,7 +107,7 @@
|
||||
"typeorm": "^0.3.17",
|
||||
"typescript-json-schema": "^0.50.1",
|
||||
"wretch": "^2.6.0",
|
||||
"ws": "^8.13.0"
|
||||
"ws": "^8.17.1"
|
||||
},
|
||||
"_moduleAliases": {
|
||||
"@spacebar/api": "dist/api",
|
||||
|
@ -1,5 +1,5 @@
|
||||
diff --git a/node_modules/express/lib/response.js b/node_modules/express/lib/response.js
|
||||
index fede486..e3d868e 100644
|
||||
index dd7b3c8..a339896 100644
|
||||
--- a/node_modules/express/lib/response.js
|
||||
+++ b/node_modules/express/lib/response.js
|
||||
@@ -27,7 +27,6 @@ var merge = require('utils-merge');
|
||||
@ -10,21 +10,15 @@ index fede486..e3d868e 100644
|
||||
var cookie = require('cookie');
|
||||
var send = require('send');
|
||||
var extname = path.extname;
|
||||
@@ -49,13 +48,6 @@ var res = Object.create(http.ServerResponse.prototype)
|
||||
@@ -54,7 +53,6 @@ module.exports = res
|
||||
* @private
|
||||
*/
|
||||
|
||||
module.exports = res
|
||||
|
||||
-/**
|
||||
- * Module variables.
|
||||
- * @private
|
||||
- */
|
||||
-
|
||||
-var charsetRegExp = /;\s*charset\s*=/;
|
||||
-
|
||||
var schemaAndHostRegExp = /^(?:[a-zA-Z][a-zA-Z0-9+.-]*:)?\/\/[^\\\/\?]+/;
|
||||
|
||||
/**
|
||||
* Set status `code`.
|
||||
*
|
||||
@@ -164,17 +156,6 @@ res.send = function send(body) {
|
||||
@@ -165,16 +163,6 @@ res.send = function send(body) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -38,11 +32,10 @@ index fede486..e3d868e 100644
|
||||
- this.set('Content-Type', setCharset(type, 'utf-8'));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
|
||||
// determine if ETag should be generated
|
||||
var etagFn = app.get('etag fn')
|
||||
var generateETag = !this.get('ETag') && typeof etagFn === 'function'
|
||||
@@ -780,17 +761,6 @@ res.header = function header(field, val) {
|
||||
@@ -781,17 +769,6 @@ res.header = function header(field, val) {
|
||||
? val.map(String)
|
||||
: String(val);
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -57,7 +57,7 @@ router.post(
|
||||
|
||||
res.send({
|
||||
token: await generateToken(user.id),
|
||||
}).status(204);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -331,4 +331,74 @@ router.delete(
|
||||
},
|
||||
);
|
||||
|
||||
router.delete(
|
||||
"/:emoji/:burst/:user_id",
|
||||
route({
|
||||
responses: {
|
||||
204: {},
|
||||
400: {
|
||||
body: "APIErrorResponse",
|
||||
},
|
||||
404: {},
|
||||
403: {},
|
||||
},
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
let { user_id } = req.params;
|
||||
const { message_id, channel_id } = req.params;
|
||||
|
||||
const emoji = getEmoji(req.params.emoji);
|
||||
|
||||
const channel = await Channel.findOneOrFail({
|
||||
where: { id: channel_id },
|
||||
});
|
||||
const message = await Message.findOneOrFail({
|
||||
where: { id: message_id, channel_id },
|
||||
});
|
||||
|
||||
if (user_id === "@me") user_id = req.user_id;
|
||||
else {
|
||||
const permissions = await getPermission(
|
||||
req.user_id,
|
||||
undefined,
|
||||
channel_id,
|
||||
);
|
||||
permissions.hasThrow("MANAGE_MESSAGES");
|
||||
}
|
||||
|
||||
const already_added = message.reactions.find(
|
||||
(x) =>
|
||||
(x.emoji.id === emoji.id && emoji.id) ||
|
||||
x.emoji.name === emoji.name,
|
||||
);
|
||||
if (!already_added || !already_added.user_ids.includes(user_id))
|
||||
throw new HTTPError("Reaction not found", 404);
|
||||
|
||||
already_added.count--;
|
||||
|
||||
if (already_added.count <= 0) message.reactions.remove(already_added);
|
||||
else
|
||||
already_added.user_ids.splice(
|
||||
already_added.user_ids.indexOf(user_id),
|
||||
1,
|
||||
);
|
||||
|
||||
await message.save();
|
||||
|
||||
await emitEvent({
|
||||
event: "MESSAGE_REACTION_REMOVE",
|
||||
channel_id,
|
||||
data: {
|
||||
user_id: req.user_id,
|
||||
channel_id,
|
||||
message_id,
|
||||
guild_id: channel.guild_id,
|
||||
emoji,
|
||||
},
|
||||
} as MessageReactionRemoveEvent);
|
||||
|
||||
res.sendStatus(204);
|
||||
},
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@ -155,12 +155,20 @@ router.get(
|
||||
} else {
|
||||
if (after) {
|
||||
if (BigInt(after) > BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
throw new HTTPError(
|
||||
"after parameter must not be greater than current time",
|
||||
422,
|
||||
);
|
||||
|
||||
query.where.id = MoreThan(after);
|
||||
query.order = { timestamp: "ASC" };
|
||||
} else if (before) {
|
||||
if (BigInt(before) > BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
throw new HTTPError(
|
||||
"before parameter must not be greater than current time",
|
||||
422,
|
||||
);
|
||||
|
||||
query.where.id = LessThan(before);
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -39,8 +39,8 @@ router.get(
|
||||
const { primary_only } = req.query;
|
||||
|
||||
const out = primary_only
|
||||
? await Categories.find()
|
||||
: await Categories.find({ where: { is_primary: true } });
|
||||
? await Categories.find({ where: { is_primary: true } })
|
||||
: await Categories.find();
|
||||
|
||||
res.send(out);
|
||||
},
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -60,7 +60,7 @@ router.post(
|
||||
}),
|
||||
]);
|
||||
|
||||
return res.status(204);
|
||||
return res.sendStatus(204);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -19,6 +19,8 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
Badge,
|
||||
Config,
|
||||
FieldErrors,
|
||||
Member,
|
||||
PrivateUserProjection,
|
||||
User,
|
||||
@ -136,6 +138,18 @@ router.patch(
|
||||
select: [...PrivateUserProjection, "data"],
|
||||
});
|
||||
|
||||
if (body.bio) {
|
||||
const { maxBio } = Config.get().limits.user;
|
||||
if (body.bio.length > maxBio) {
|
||||
throw FieldErrors({
|
||||
bio: {
|
||||
code: "BIO_INVALID",
|
||||
message: `Bio must be less than ${maxBio} in length`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
user.assign(body);
|
||||
await user.save();
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -189,6 +189,18 @@ router.patch(
|
||||
}
|
||||
}
|
||||
|
||||
if (body.bio) {
|
||||
const { maxBio } = Config.get().limits.user;
|
||||
if (body.bio.length > maxBio) {
|
||||
throw FieldErrors({
|
||||
bio: {
|
||||
code: "BIO_INVALID",
|
||||
message: `Bio must be less than ${maxBio} in length`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
user.assign(body);
|
||||
user.validate();
|
||||
await user.save();
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -107,7 +107,7 @@ router.put(
|
||||
user_id: owner.id,
|
||||
});
|
||||
|
||||
return res.status(204);
|
||||
return res.sendStatus(204);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -50,7 +50,7 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) {
|
||||
} as SessionsReplace);
|
||||
const session = sessions.first() || {
|
||||
activities: [],
|
||||
client_info: {},
|
||||
client_status: {},
|
||||
status: "offline",
|
||||
};
|
||||
|
||||
@ -68,7 +68,7 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) {
|
||||
data: {
|
||||
user: userOrId,
|
||||
activities: session.activities,
|
||||
client_status: session?.client_info,
|
||||
client_status: session?.client_status,
|
||||
status: session.status,
|
||||
},
|
||||
} as PresenceUpdateEvent);
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -122,10 +122,11 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
session_id: this.session_id,
|
||||
status: identify.presence?.status || "online",
|
||||
client_info: {
|
||||
client: identify.properties?.$device,
|
||||
os: identify.properties?.os,
|
||||
client: identify.properties?.device || identify.properties?.$device,
|
||||
os: identify.properties?.os || identify.properties?.$os,
|
||||
version: 0,
|
||||
},
|
||||
client_status: {},
|
||||
activities: identify.presence?.activities, // TODO: validation
|
||||
});
|
||||
|
||||
@ -372,7 +373,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
data: {
|
||||
user: user.toPublicUser(),
|
||||
activities: session.activities,
|
||||
client_status: session.client_info,
|
||||
client_status: session.client_status,
|
||||
status: session.status,
|
||||
},
|
||||
} as PresenceUpdateEvent),
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -248,7 +248,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
||||
d: {
|
||||
user: user,
|
||||
activities: session?.activities || [],
|
||||
client_status: session?.client_info,
|
||||
client_status: session?.client_status,
|
||||
status: session?.status || "offline",
|
||||
} as Presence,
|
||||
});
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -35,14 +35,19 @@ export async function onPresenceUpdate(this: WebSocket, { d }: Payload) {
|
||||
{ status: presence.status, activities: presence.activities },
|
||||
);
|
||||
|
||||
const session = await Session.findOneOrFail({
|
||||
select: ["client_status"],
|
||||
where: { session_id: this.session_id },
|
||||
});
|
||||
|
||||
await emitEvent({
|
||||
event: "PRESENCE_UPDATE",
|
||||
user_id: this.user_id,
|
||||
data: {
|
||||
user: await User.getPublicUser(this.user_id),
|
||||
activities: presence.activities,
|
||||
client_status: {}, // TODO:
|
||||
status: presence.status,
|
||||
activities: presence.activities,
|
||||
client_status: session.client_status,
|
||||
},
|
||||
} as PresenceUpdateEvent);
|
||||
}
|
||||
|
@ -1,23 +1,124 @@
|
||||
/*
|
||||
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 { WebSocket } from "@spacebar/gateway";
|
||||
import {
|
||||
getPermission,
|
||||
GuildMembersChunkEvent,
|
||||
Member,
|
||||
Presence,
|
||||
RequestGuildMembersSchema,
|
||||
Session,
|
||||
} from "@spacebar/util";
|
||||
import { WebSocket, Payload, OPCODES, Send } from "@spacebar/gateway";
|
||||
import { check } from "./instanceOf";
|
||||
import { FindManyOptions, In, Like } from "typeorm";
|
||||
|
||||
export function onRequestGuildMembers(this: WebSocket) {
|
||||
// return this.close(CLOSECODES.Unknown_error);
|
||||
export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) {
|
||||
// TODO: check data
|
||||
check.call(this, RequestGuildMembersSchema, d);
|
||||
|
||||
const { guild_id, query, presences, nonce } =
|
||||
d as RequestGuildMembersSchema;
|
||||
let { limit, user_ids } = d as RequestGuildMembersSchema;
|
||||
|
||||
if ("query" in d && (!limit || Number.isNaN(limit)))
|
||||
throw new Error('"query" requires "limit" to be set');
|
||||
if ("query" in d && user_ids)
|
||||
throw new Error('"query" and "user_ids" are mutually exclusive');
|
||||
if (user_ids && !Array.isArray(user_ids)) user_ids = [user_ids];
|
||||
user_ids = user_ids as string[] | undefined;
|
||||
|
||||
// TODO: Configurable limit?
|
||||
if ((query || (user_ids && user_ids.length > 0)) && (!limit || limit > 100))
|
||||
limit = 100;
|
||||
|
||||
const permissions = await getPermission(this.user_id, guild_id);
|
||||
permissions.hasThrow("VIEW_CHANNEL");
|
||||
|
||||
const whereQuery: FindManyOptions["where"] = {};
|
||||
if (query) {
|
||||
whereQuery.user = {
|
||||
username: Like(query + "%"),
|
||||
};
|
||||
} else if (user_ids && user_ids.length > 0) {
|
||||
whereQuery.id = In(user_ids);
|
||||
}
|
||||
|
||||
const memberFind: FindManyOptions = {
|
||||
where: {
|
||||
...whereQuery,
|
||||
guild_id,
|
||||
},
|
||||
relations: ["user", "roles"],
|
||||
};
|
||||
if (limit) memberFind.take = Math.abs(Number(limit || 100));
|
||||
const members = await Member.find(memberFind);
|
||||
|
||||
const baseData = {
|
||||
guild_id,
|
||||
nonce,
|
||||
};
|
||||
|
||||
const chunkCount = Math.ceil(members.length / 1000);
|
||||
|
||||
let notFound: string[] = [];
|
||||
if (user_ids && user_ids.length > 0)
|
||||
notFound = user_ids.filter(
|
||||
(id) => !members.some((member) => member.id == id),
|
||||
);
|
||||
|
||||
const chunks: GuildMembersChunkEvent["data"][] = [];
|
||||
while (members.length > 0) {
|
||||
const chunk: Member[] = members.splice(0, 1000);
|
||||
|
||||
const presenceList: Presence[] = [];
|
||||
if (presences) {
|
||||
for await (const member of chunk) {
|
||||
const session = await Session.findOne({
|
||||
where: { user_id: member.id },
|
||||
});
|
||||
if (session)
|
||||
presenceList.push({
|
||||
user: member.user.toPublicUser(),
|
||||
status: session.status,
|
||||
activities: session.activities,
|
||||
client_status: session.client_status,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
chunks.push({
|
||||
...baseData,
|
||||
members: chunk.map((member) => member.toPublicMember()),
|
||||
presences: presences ? presenceList : undefined,
|
||||
chunk_index: chunks.length,
|
||||
chunk_count: chunkCount,
|
||||
});
|
||||
}
|
||||
|
||||
if (notFound.length > 0) chunks[0].not_found = notFound;
|
||||
|
||||
chunks.forEach((chunk) => {
|
||||
Send(this, {
|
||||
op: OPCODES.Dispatch,
|
||||
s: this.sequence++,
|
||||
t: "GUILD_MEMBERS_CHUNK",
|
||||
d: chunk,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -20,4 +20,5 @@ export class UserLimits {
|
||||
maxGuilds: number = 1048576;
|
||||
maxUsername: number = 32;
|
||||
maxFriends: number = 5000;
|
||||
maxBio: number = 190;
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -46,6 +46,10 @@ export class Categories extends BaseClassWithoutId {
|
||||
@Column({ type: "simple-json" })
|
||||
localizations: string;
|
||||
|
||||
// Whether to show the category prominently (e.g. in a sidebar) instead of only secondary (e.g. in search results)
|
||||
@Column({ nullable: true })
|
||||
is_primary: boolean;
|
||||
|
||||
@Column({ nullable: true })
|
||||
icon?: string;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ export class Message extends BaseClass {
|
||||
...this,
|
||||
author_id: undefined,
|
||||
member_id: undefined,
|
||||
webhook_id: undefined,
|
||||
webhook_id: this.webhook_id ?? undefined,
|
||||
application_id: undefined,
|
||||
|
||||
nonce: this.nonce ?? undefined,
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -19,7 +19,7 @@
|
||||
import { User } from "./User";
|
||||
import { BaseClass } from "./BaseClass";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||
import { Status } from "../interfaces/Status";
|
||||
import { ClientStatus, Status } from "../interfaces/Status";
|
||||
import { Activity } from "../interfaces/Activity";
|
||||
|
||||
//TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them
|
||||
@ -43,7 +43,6 @@ export class Session extends BaseClass {
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
activities: Activity[];
|
||||
|
||||
// TODO client_status
|
||||
@Column({ type: "simple-json", select: false })
|
||||
client_info: {
|
||||
client: string;
|
||||
@ -51,6 +50,9 @@ export class Session extends BaseClass {
|
||||
version: number;
|
||||
};
|
||||
|
||||
@Column({ type: "simple-json" })
|
||||
client_status: ClientStatus;
|
||||
|
||||
@Column({ nullable: false, type: "varchar" })
|
||||
status: Status; //TODO enum
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -130,7 +130,7 @@ export class User extends BaseClass {
|
||||
bot: boolean = false; // if user is bot
|
||||
|
||||
@Column()
|
||||
bio: string = ""; // short description of the user (max 190 chars -> should be configurable)
|
||||
bio: string = ""; // short description of the user
|
||||
|
||||
@Column()
|
||||
system: boolean = false; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -280,8 +280,8 @@ export interface GuildMembersChunkEvent extends Event {
|
||||
members: PublicMember[];
|
||||
chunk_index: number;
|
||||
chunk_count: number;
|
||||
not_found: string[];
|
||||
presences: Presence[];
|
||||
not_found?: string[];
|
||||
presences?: Presence[];
|
||||
nonce?: string;
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -21,5 +21,6 @@ export type Status = "idle" | "dnd" | "online" | "offline" | "invisible";
|
||||
export interface ClientStatus {
|
||||
desktop?: string; // e.g. Windows/Linux/Mac
|
||||
mobile?: string; // e.g. iOS/Android
|
||||
web?: string; // e.g. browser, bot account
|
||||
web?: string; // e.g. browser, bot account, unknown
|
||||
embedded?: string; // e.g. embedded
|
||||
}
|
||||
|
17
src/util/migration/mariadb/1723347738541-client_status.ts
Normal file
17
src/util/migration/mariadb/1723347738541-client_status.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class client_status1723347738541 implements MigrationInterface {
|
||||
name = "client_status1723347738541";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `sessions` ADD `client_status` text NULL AFTER `client_info`",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `sessions` DROP COLUMN `client_status`",
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class DiscoveryCategoryIcon1723577874393 implements MigrationInterface {
|
||||
name = "DiscoveryCategoryIcon1723577874393";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `categories` ADD `icon` text NULL",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query("ALTER TABLE `categories` DROP COLUMN `icon`");
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class WebhookSourceChannel1723644478176 implements MigrationInterface {
|
||||
name = "WebhookSourceChannel1723644478176";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` ADD COLUMN `source_channel_id` VARCHAR(255) NULL DEFAULT NULL AFTER `source_guild_id`",
|
||||
);
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` ADD CONSTRAINT `FK_d64f38834fa676f6caa4786ddd6` FOREIGN KEY (`source_channel_id`) REFERENCES `channels` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` DROP FOREIGN KEY `FK_d64f38834fa676f6caa4786ddd6`",
|
||||
);
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` DROP COLUMN `source_channel_id`",
|
||||
);
|
||||
}
|
||||
}
|
17
src/util/migration/mysql/1723347738541-client_status.ts
Normal file
17
src/util/migration/mysql/1723347738541-client_status.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class client_status1723347738541 implements MigrationInterface {
|
||||
name = "client_status1723347738541";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `sessions` ADD `client_status` text NULL AFTER `client_info`",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `sessions` DROP COLUMN `client_status`",
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class DiscoveryCategoryIcon1723577874393 implements MigrationInterface {
|
||||
name = "DiscoveryCategoryIcon1723577874393";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `categories` ADD `icon` text NULL",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query("ALTER TABLE `categories` DROP COLUMN `icon`");
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class WebhookSourceChannel1723644478176 implements MigrationInterface {
|
||||
name = "WebhookSourceChannel1723644478176";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` ADD COLUMN `source_channel_id` VARCHAR(255) NULL DEFAULT NULL AFTER `source_guild_id`",
|
||||
);
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` ADD CONSTRAINT `FK_d64f38834fa676f6caa4786ddd6` FOREIGN KEY (`source_channel_id`) REFERENCES `channels` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` DROP FOREIGN KEY `FK_d64f38834fa676f6caa4786ddd6`",
|
||||
);
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE `webhooks` DROP COLUMN `source_channel_id`",
|
||||
);
|
||||
}
|
||||
}
|
17
src/util/migration/postgres/1723347738541-client_status.ts
Normal file
17
src/util/migration/postgres/1723347738541-client_status.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class client_status1723347738541 implements MigrationInterface {
|
||||
name = "client_status1723347738541";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE sessions ADD client_status text NULL",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE sessions DROP COLUMN client_status",
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class DiscoveryCategoryIcon1723577874393 implements MigrationInterface {
|
||||
name = "DiscoveryCategoryIcon1723577874393";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query("ALTER TABLE categories ADD icon text NULL");
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query("ALTER TABLE categories DROP COLUMN icon");
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class WebhookSourceChannel1723644478176 implements MigrationInterface {
|
||||
name = "WebhookSourceChannel1723644478176";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE webhooks ADD COLUMN source_channel_id VARCHAR(255) NULL DEFAULT NULL",
|
||||
);
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE webhooks ADD CONSTRAINT FK_d64f38834fa676f6caa4786ddd6 FOREIGN KEY (source_channel_id) REFERENCES channels (id) ON UPDATE NO ACTION ON DELETE CASCADE",
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE webhooks DROP CONSTRAINT FK_d64f38834fa676f6caa4786ddd6",
|
||||
);
|
||||
await queryRunner.query(
|
||||
"ALTER TABLE webhooks DROP COLUMN source_channel_id",
|
||||
);
|
||||
}
|
||||
}
|
35
src/util/schemas/RequestGuildMembersSchema.ts
Normal file
35
src/util/schemas/RequestGuildMembersSchema.ts
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
export interface RequestGuildMembersSchema {
|
||||
guild_id: string;
|
||||
query?: string;
|
||||
limit?: number;
|
||||
presences?: boolean;
|
||||
user_ids?: string | string[];
|
||||
nonce?: string;
|
||||
}
|
||||
|
||||
export const RequestGuildMembersSchema = {
|
||||
guild_id: String,
|
||||
$query: String,
|
||||
$limit: Number,
|
||||
$presences: Boolean,
|
||||
$user_ids: [] as string | string[],
|
||||
$nonce: String,
|
||||
};
|
@ -23,9 +23,6 @@ export interface UserModifySchema {
|
||||
*/
|
||||
username?: string;
|
||||
avatar?: string | null;
|
||||
/**
|
||||
* @maxLength 1024
|
||||
*/
|
||||
bio?: string;
|
||||
accent_color?: number;
|
||||
banner?: string | null;
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
@ -58,6 +58,7 @@ export * from "./PurgeSchema";
|
||||
export * from "./RegisterSchema";
|
||||
export * from "./RelationshipPostSchema";
|
||||
export * from "./RelationshipPutSchema";
|
||||
export * from "./RequestGuildMembersSchema";
|
||||
export * from "./RoleModifySchema";
|
||||
export * from "./RolePositionUpdateSchema";
|
||||
export * from "./SelectProtocolSchema";
|
||||
|
Loading…
Reference in New Issue
Block a user