1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 12:42:44 +01:00

Merge branch 'master' into slowcord

This commit is contained in:
Madeline 2022-02-18 10:47:18 +11:00
commit 688b33960b
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
32 changed files with 546 additions and 140 deletions

View File

@ -26,7 +26,6 @@ h3.title-jXR8lp.marginBottom8-AtZOdT.base-1x0h_U.size24-RIRrxO::after {
width: 130px;
height: 23px;
background-size: contain;
border-radius: 50%;
}
/* replace TOS text */

View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html class="theme-dark" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" name="viewport" />
<link rel="stylesheet" href="/assets/532.03aaeef88460fae60534.css" integrity="" />
<link rel="icon" href="/assets/07dca80a102d4149e9736d4b162cff6f.ico" />
<title>Discord Test Client Developer Portal</title>
<meta charset="utf-8" data-react-helmet="true" />
</head>
<body>
<div id="app-mount"></div>
<script>
window.GLOBAL_ENV = {
API_VERSION: 9,
API_ENDPOINT: "/api",
WEBAPP_ENDPOINT: "",
CDN_HOST: `${location.hostname}:3003`,
BRAINTREE_KEY: "production_5st77rrc_49pp2rp4phym7387",
STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
MARKETING_ENDPOINT: "//discord.com",
RELEASE_CHANNEL: "stable",
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
};
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
const localStorage = window.localStorage;
// TODO: remote auth
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT);
localStorage.setItem(
"DeveloperOptionsStore",
`{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}`
);
</script>
<script src="/assets/41fde19fdf180f3d4315.js" integrity=""></script>
<script src="/assets/7b04a3ab10e05dd9054e.js" integrity=""></script>
<script src="/assets/d1f811da193e5648048b.js" integrity=""></script>
</body>
</html>

48
api/package-lock.json generated
View File

@ -34,7 +34,6 @@
"missing-native-js-functions": "^1.2.18",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"node": ">=15.0",
"node-fetch": "^3.1.1",
"patch-package": "^6.4.7",
"picocolors": "^1.0.0",
@ -9605,9 +9604,9 @@
}
},
"node_modules/acorn": {
"version": "8.5.0",
"integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==",
"dev": true,
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"bin": {
"acorn": "bin/acorn"
},
@ -15193,9 +15192,13 @@
}
},
"node_modules/vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng==",
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"dependencies": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"bin": {
"vm2": "bin/vm2"
},
@ -15203,6 +15206,14 @@
"node": ">=6.0"
}
},
"node_modules/vm2/node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/w3c-hr-time": {
"version": "1.0.2",
"integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==",
@ -22768,9 +22779,9 @@
}
},
"acorn": {
"version": "8.5.0",
"integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==",
"dev": true
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ=="
},
"acorn-globals": {
"version": "6.0.0",
@ -26895,9 +26906,20 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng=="
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"requires": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"dependencies": {
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA=="
}
}
},
"w3c-hr-time": {
"version": "1.0.2",

View File

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

View File

@ -5,7 +5,7 @@ const router: Router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
//TODO
res.json([]).status(200);
res.send([]).status(200);
});
export default router;

View File

@ -0,0 +1,11 @@
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
const router: Router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
//TODO
res.send([]).status(200);
});
export default router;

View File

@ -6,15 +6,29 @@ import { route } from "@fosscord/api";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const { limit } = req.params;
var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery;
const { offset, limit, categories } = req.query;
var showAllGuilds = Config.get().guild.discovery.showAllGuilds;
var configLimit = Config.get().guild.discovery.limit;
// ! this only works using SQL querys
// TODO: implement this with default typeorm query
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
const guilds = showAllGuilds
? await Guild.find({ take: Math.abs(Number(limit || 20)) })
: await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 20)) });
res.send({ guilds: guilds });
let guilds;
if (categories == undefined) {
guilds = showAllGuilds
? await Guild.find({ take: Math.abs(Number(limit || configLimit)) })
: await Guild.find({ where: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || configLimit)) });
} else {
guilds = showAllGuilds
? await Guild.find({ where: `"primary_category_id" = ${categories}`, take: Math.abs(Number(limit || configLimit)) })
: await Guild.find({
where: `"primary_category_id" = ${categories} AND "features" LIKE '%DISCOVERABLE%'`,
take: Math.abs(Number(limit || configLimit))
});
}
const total = guilds ? guilds.length : undefined;
res.send({ total: total, guilds: guilds, offset: Number(offset || Config.get().guild.discovery.offset), limit: Number(limit || configLimit) });
});
export default router;

View File

@ -1,12 +1,18 @@
import { Categories } from "@fosscord/util";
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
const router = Router();
router.get("/categories", route({}), (req: Request, res: Response) => {
router.get("/categories", route({}), async (req: Request, res: Response) => {
// TODO:
//const { locale, primary_only } = req.query;
res.json([]).status(200);
// Get locale instead
const { locale, primary_only } = req.query;
const out = primary_only ? await Categories.find() : await Categories.find({ where: `"is_primary" = "true"` });
res.send(out);
});
export default router;

View File

@ -5,7 +5,7 @@ const router = Router();
router.get("/", route({}), (req: Request, res: Response) => {
// TODO:
res.send({ fingerprint: "", assignments: [] });
res.send({ fingerprint: "", assignments: [], guild_experiments:[] });
});
export default router;

View File

@ -6,15 +6,18 @@ import { route } from "@fosscord/api";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const { limit, personalization_disabled } = req.params;
var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery;
const { limit, personalization_disabled } = req.query;
var showAllGuilds = Config.get().guild.discovery.showAllGuilds;
// ! this only works using SQL querys
// TODO: implement this with default typeorm query
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
const genLoadId = (size: Number) => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
const guilds = showAllGuilds
? await Guild.find({ take: Math.abs(Number(limit || 20)) })
: await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 100)) });
res.send({ recommended_guilds: guilds });
? await Guild.find({ take: Math.abs(Number(limit || 24)) })
: await Guild.find({ where: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || 24)) });
res.send({ recommended_guilds: guilds, load_id: `server_recs/${genLoadId(32)}`}).status(200);
});
export default router;

View File

@ -0,0 +1,39 @@
import { Guild, Config } from "@fosscord/util";
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const { guild_id } = req.params;
// TODO:
// Load from database
// Admin control, but for now it allows anyone to be discoverable
res.send({
guild_id: guild_id,
safe_environment: true,
healthy: true,
health_score_pending: false,
size: true,
nsfw_properties: {},
protected: true,
sufficient: true,
sufficient_without_grace_period: true,
valid_rules_channel: true,
retention_healthy: true,
engagement_healthy: true,
age: true,
minimum_age: 0,
health_score: {
avg_nonnew_participators: 0,
avg_nonnew_communicators: 0,
num_intentful_joiners: 0,
perc_ret_w1_intentful: 0
},
minimum_size: 0
});
});
export default router;

View File

@ -34,7 +34,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
// @ts-ignore
guild.joined_at = member?.joined_at;
return res.json(guild);
return res.send(guild);
});
router.patch("/", route({ body: "GuildUpdateSchema", permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => {

View File

@ -1,5 +1,5 @@
import { Request, Response, Router } from "express";
import { Member, getPermission, Role, GuildMemberUpdateEvent, emitEvent } from "@fosscord/util";
import { Member, getPermission, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Guild } from "@fosscord/util";
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
@ -43,13 +43,26 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
});
router.put("/", route({}), async (req: Request, res: Response) => {
// TODO: Lurker mode
let { guild_id, member_id } = req.params;
if (member_id === "@me") member_id = req.user_id;
throw new HTTPError("Maintenance: Currently you can't add a member", 403);
// TODO: only for oauth2 applications
var guild = await Guild.findOneOrFail({
where: { id: guild_id } });
var emoji = await Emoji.find({
where: { guild_id: guild_id } });
var roles = await Role.find({
where: { guild_id: guild_id } });
var stickers = await Sticker.find({
where: { guild_id: guild_id } });
await Member.addToGuild(member_id, guild_id);
res.sendStatus(204);
res.send({...guild, emojis: emoji, roles: roles, stickers: stickers});
});
router.delete("/", route({ permission: "KICK_MEMBERS" }), async (req: Request, res: Response) => {

View File

@ -0,0 +1,40 @@
import { Guild, Config } from "@fosscord/util";
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const { guild_id } = req.params;
// TODO:
// Load from database
// Admin control, but for now it allows anyone to be discoverable
res.send({
guild_id: guild_id,
safe_environment: true,
healthy: true,
health_score_pending: false,
size: true,
nsfw_properties: {},
protected: true,
sufficient: true,
sufficient_without_grace_period: true,
valid_rules_channel: true,
retention_healthy: true,
engagement_healthy: true,
age: true,
minimum_age: 0,
health_score: {
avg_nonnew_participators: 0,
avg_nonnew_communicators: 0,
num_intentful_joiners: 0,
perc_ret_w1_intentful: 0
},
minimum_size: 0
});
});
export default router;

11
api/src/routes/teams.ts Normal file
View File

@ -0,0 +1,11 @@
import { Request, Response, Router } from "express";
import { route } from "@fosscord/api";
const router: Router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
//TODO
res.send([]);
});
export default router;

View File

@ -1,5 +1,5 @@
import { Router, Request, Response } from "express";
import { PublicConnectedAccount, PublicUser, User, UserPublic } from "@fosscord/util";
import { PublicConnectedAccount, PublicUser, User, UserPublic, Member } from "@fosscord/util";
import { route } from "@fosscord/api";
const router: Router = Router();
@ -15,11 +15,24 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }),
if (req.params.id === "@me") req.params.id = req.user_id;
const user = await User.getPublicUser(req.params.id, { relations: ["connected_accounts"] });
var mutual_guilds: object[] = [];
const requested_member = await Member.find( { id: req.params.id, })
const self_member = await Member.find( { id: req.user_id, })
for(const rmem of requested_member) {
for(const smem of self_member) {
if (smem.guild_id === rmem.guild_id) {
mutual_guilds.push({id: rmem.guild_id, nick: rmem.nick})
}
}
}
res.json({
connected_accounts: user.connected_accounts,
premium_guild_since: null, // TODO
premium_since: null, // TODO
mutual_guilds: [], // TODO {id: "", nick: null} when ?with_mutual_guilds=true
mutual_guilds: mutual_guilds, // TODO {id: "", nick: null} when ?with_mutual_guilds=true
user: {
username: user.username,
discriminator: user.discriminator,

View File

@ -0,0 +1,41 @@
import { Router, Request, Response } from "express";
import { User } from "@fosscord/util";
import { route } from "@fosscord/api";
const router: Router = Router();
export interface UserRelationsResponse {
object: {
id?: string,
username?: string,
avatar?: string,
discriminator?: string,
public_flags?: number
}
}
router.get("/", route({ test: { response: { body: "UserRelationsResponse" } } }), async (req: Request, res: Response) => {
var mutual_relations: object[] = [];
const requested_relations = await User.findOneOrFail({
where: { id: req.params.id },
relations: ["relationships"]
});
const self_relations = await User.findOneOrFail({
where: { id: req.user_id },
relations: ["relationships"]
});
for(const rmem of requested_relations.relationships) {
for(const smem of self_relations.relationships)
if (rmem.to_id === smem.to_id && rmem.type === 1 && rmem.to_id !== req.user_id) {
var relation_user = await User.getPublicUser(rmem.to_id)
mutual_relations.push({id: relation_user.id, username: relation_user.username, avatar: relation_user.avatar, discriminator: relation_user.discriminator, public_flags: relation_user.public_flags})
}
}
res.json(mutual_relations)
});
export default router;

View File

@ -8,7 +8,13 @@ const router: Router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const members = await Member.find({ relations: ["guild"], where: { id: req.user_id } });
res.json(members.map((x) => x.guild));
let guild = members.map((x) => x.guild);
if ("with_counts" in req.query && req.query.with_counts == "true") {
guild = []; // TODO: Load guilds with user role permissions number
}
res.json(guild);
});
// user send to leave a certain guild

View File

@ -57,6 +57,13 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
user.data.hash = await bcrypt.hash(body.new_password, 12);
}
var check_username = body?.username?.replace(/\s/g, '');
if(!check_username) {
throw FieldErrors({
username: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") }
});
}
await user.save();
// @ts-ignore

View File

@ -73,7 +73,7 @@ const normalizeBody = (body: any = {}) => {
} else {
for (const [key, value] of Object.entries(object)) {
if (value == null) {
if (key === "icon" || key === "avatar" || key === "banner" || key === "splash") continue;
if (key === "icon" || key === "avatar" || key === "banner" || key === "splash" || key === "discovery_splash") continue;
delete object[key];
} else if (typeof value === "object") {
normalizeObject(value);

View File

@ -3603,12 +3603,6 @@
"integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==",
"dev": true
},
"node_modules/@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
"node_modules/@types/jsonwebtoken": {
"version": "8.5.5",
"integrity": "sha512-OGqtHQ7N5/Ap/TUwO6IgHDuLiAoTmHhGpNvgkCm/F4N6pKzx/RBSfr2OXZSwC6vkfnsEdb6+7DNZVtiXiwdwFw==",
@ -8328,17 +8322,6 @@
"node": ">= 4.0.0"
}
},
"node_modules/pac-proxy-agent/node_modules/vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng==",
"bin": {
"vm2": "bin/vm2"
},
"engines": {
"node": ">=6.0"
}
},
"node_modules/pac-proxy-agent/node_modules/xregexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz",
@ -10476,6 +10459,7 @@
"node_modules/typescript": {
"version": "4.4.3",
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@ -10695,6 +10679,40 @@
"node": ">= 0.8"
}
},
"node_modules/vm2": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"dependencies": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"bin": {
"vm2": "bin/vm2"
},
"engines": {
"node": ">=6.0"
}
},
"node_modules/vm2/node_modules/acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/vm2/node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/w3c-hr-time": {
"version": "1.0.2",
"integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==",
@ -13707,12 +13725,6 @@
"integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==",
"dev": true
},
"@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
"@types/jsonwebtoken": {
"version": "8.5.5",
"integrity": "sha512-OGqtHQ7N5/Ap/TUwO6IgHDuLiAoTmHhGpNvgkCm/F4N6pKzx/RBSfr2OXZSwC6vkfnsEdb6+7DNZVtiXiwdwFw==",
@ -17243,11 +17255,6 @@
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng=="
},
"xregexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz",
@ -18769,7 +18776,8 @@
},
"typescript": {
"version": "4.4.3",
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA=="
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
"dev": true
},
"typescript-cached-transpile": {
"version": "0.0.6",
@ -18938,6 +18946,27 @@
"version": "1.1.2",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"vm2": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"requires": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"dependencies": {
"acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ=="
},
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA=="
}
}
},
"w3c-hr-time": {
"version": "1.0.2",
"integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==",

12
cdn/package-lock.json generated
View File

@ -3921,9 +3921,9 @@
}
},
"node_modules/follow-redirects": {
"version": "1.14.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz",
"integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
"funding": [
{
"type": "individual",
@ -10926,9 +10926,9 @@
}
},
"follow-redirects": {
"version": "1.14.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz",
"integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
"peer": true
},
"form-data": {

View File

@ -7254,6 +7254,25 @@
"node": ">= 0.6"
}
},
"node_modules/acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/agent-base": {
"version": "6.0.2",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
@ -9904,9 +9923,13 @@
}
},
"node_modules/vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng==",
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"dependencies": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"bin": {
"vm2": "bin/vm2"
},
@ -15686,6 +15709,16 @@
"negotiator": "0.6.2"
}
},
"acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ=="
},
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA=="
},
"agent-base": {
"version": "6.0.2",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
@ -17612,9 +17645,13 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng=="
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"requires": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
}
},
"webidl-conversions": {
"version": "3.0.1",

49
util/package-lock.json generated
View File

@ -1324,10 +1324,9 @@
}
},
"node_modules/acorn": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz",
"integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==",
"dev": true,
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"bin": {
"acorn": "bin/acorn"
},
@ -7710,9 +7709,13 @@
"peer": true
},
"node_modules/vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng==",
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"dependencies": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"bin": {
"vm2": "bin/vm2"
},
@ -7720,6 +7723,14 @@
"node": ">=6.0"
}
},
"node_modules/vm2/node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/w3c-hr-time": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz",
@ -9151,10 +9162,9 @@
}
},
"acorn": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz",
"integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==",
"dev": true
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ=="
},
"acorn-globals": {
"version": "6.0.0",
@ -14090,9 +14100,20 @@
}
},
"vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng=="
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"requires": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"dependencies": {
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA=="
}
}
},
"w3c-hr-time": {
"version": "1.0.2",

View File

@ -0,0 +1,33 @@
import { PrimaryColumn, Column, Entity} from "typeorm";
import { BaseClassWithoutId } from "./BaseClass";
// TODO: categories:
// [{
// "id": 16,
// "default": "Anime & Manga",
// "localizations": {
// "de": "Anime & Manga",
// "fr": "Anim\u00e9s et mangas",
// "ru": "\u0410\u043d\u0438\u043c\u0435 \u0438 \u043c\u0430\u043d\u0433\u0430"
// }
// },
// "is_primary": false/true
// }]
// Also populate discord default categories
@Entity("categories")
export class Categories extends BaseClassWithoutId { // Not using snowflake
@PrimaryColumn()
id: number;
@Column({ nullable: true })
name: string;
@Column({ type: "simple-json" })
localizations: string;
@Column({ nullable: true })
is_primary: boolean;
}

View File

@ -157,7 +157,12 @@ export interface ConfigValue {
available: Region[];
};
guild: {
showAllGuildsInDiscovery: boolean;
discovery: {
showAllGuilds: boolean;
useRecommendation: boolean; // TODO: Recommendation, privacy concern?
offset: number;
limit: number;
};
autoJoin: {
enabled: boolean;
guilds: string[];
@ -353,7 +358,12 @@ export const DefaultConfigOptions: ConfigValue = {
],
},
guild: {
showAllGuildsInDiscovery: false,
discovery: {
showAllGuilds: false,
useRecommendation: false,
offset: 0,
limit: 24,
},
autoJoin: {
enabled: true,
canLeave: true,

View File

@ -17,28 +17,6 @@ import { Webhook } from "./Webhook";
// TODO: guild_scheduled_events
// TODO: stage_instances
// TODO: threads
// TODO: categories:
// [{
// "id": 16,
// "name": {
// "default": "Anime & Manga",
// "localizations": {
// "de": "Anime & Manga",
// "fr": "Anim\u00e9s et mangas",
// "ru": "\u0410\u043d\u0438\u043c\u0435 \u0438 \u043c\u0430\u043d\u0433\u0430"
// }
// },
// "is_primary": false
// }]
// TODO:
// primary_category :{
// id: 1,
// name: {
// default: "Gaming",
// localizations: { de: "Gaming", fr: "Gaming", ru: "\u0418\u0433\u0440\u044b" },
// is_primary: true,
// },
// };
// TODO:
// "keywords": [
// "Genshin Impact",
@ -107,6 +85,9 @@ export class Guild extends BaseClass {
features: string[]; //TODO use enum
//TODO: https://discord.com/developers/docs/resources/guild#guild-object-guild-features
@Column({ nullable: true })
primary_category_id: number;
@Column({ nullable: true })
icon?: string;
@ -289,6 +270,9 @@ export class Guild extends BaseClass {
@Column({ nullable: true })
nsfw?: boolean;
// only for developer portal
permissions?: number;
static async createGuild(body: {
name?: string;
icon?: string | null;
@ -306,6 +290,7 @@ export class Guild extends BaseClass {
default_message_notifications: 1, // defaults effect: setting the push default at mentions-only will save a lot
explicit_content_filter: 0,
features: [],
primary_category_id: null,
id: guild_id,
max_members: 250000,
max_presences: 250000,

View File

@ -256,7 +256,7 @@ export class User extends BaseClass {
disabled: false,
deleted: false,
email: email,
rights: "0",
rights: "0", // TODO: grant rights correctly, as 0 actually stands for no rights at all
nsfw_allowed: true, // TODO: depending on age
public_flags: "0",
flags: "0", // TODO: generate
@ -283,23 +283,18 @@ export class User extends BaseClass {
}
export const defaultSettings: UserSettings = {
afk_timeout: 300,
afk_timeout: 3600,
allow_accessibility_detection: true,
animate_emoji: true,
animate_stickers: 0,
contact_sync_enabled: false,
convert_emoticons: false,
custom_status: {
emoji_id: undefined,
emoji_name: undefined,
expires_at: undefined,
text: undefined,
},
custom_status: null,
default_guilds_restricted: false,
detect_platform_accounts: true,
developer_mode: false,
disable_games_tab: false,
enable_tts_command: true,
detect_platform_accounts: false,
developer_mode: true,
disable_games_tab: true,
enable_tts_command: false,
explicit_content_filter: 0,
friend_source_flags: { all: true },
gateway_connected: false,
@ -309,17 +304,16 @@ export const defaultSettings: UserSettings = {
inline_attachment_media: true,
inline_embed_media: true,
locale: "en-US",
message_display_compact: false,
message_display_compact: true,
native_phone_integration_enabled: true,
render_embeds: true,
render_reactions: true,
restricted_guilds: [],
show_current_game: true,
status: "online",
stream_notifications_enabled: true,
stream_notifications_enabled: false,
theme: "dark",
timezone_offset: 0,
// timezone_offset: // TODO: timezone from request
timezone_offset: 0, // TODO: timezone from request
};
export interface UserSettings {
@ -334,7 +328,7 @@ export interface UserSettings {
emoji_name?: string;
expires_at?: number;
text?: string;
};
} | null;
default_guilds_restricted: boolean;
detect_platform_accounts: boolean;
developer_mode: boolean;

View File

@ -3,6 +3,7 @@ export * from "./Attachment";
export * from "./AuditLog";
export * from "./Ban";
export * from "./BaseClass";
export * from "./Categories";
export * from "./Channel";
export * from "./Config";
export * from "./ConnectedAccount";

View File

@ -0,0 +1 @@
//TODO: populate default discord categories + init, get and set methods

View File

@ -727,26 +727,44 @@ export const DiscordApiErrors = {
* An error encountered while performing an API request (Fosscord only). Here are the potential errors:
*/
export const FosscordApiErrors = {
MANUALLY_TRIGGERED_ERROR: new ApiError("This is an artificial error", 1),
PREMIUM_DISABLED_FOR_GUILD: new ApiError("This guild cannot be boosted", 25001),
NO_FURTHER_PREMIUM: new ApiError("This guild does not receive further boosts", 25002),
GUILD_PREMIUM_DISABLED_FOR_YOU: new ApiError("This guild cannot be boosted by you", 25003),
CANNOT_FRIEND_SELF: new ApiError("Cannot friend oneself", 25009),
USER_SPECIFIC_INVITE_WRONG_RECIPIENT: new ApiError("This invite is not meant for you", 25010),
USER_SPECIFIC_INVITE_FAILED: new ApiError("Failed to invite user", 25011),
CANNOT_MODIFY_USER_GROUP: new ApiError("This user cannot manipulate this group", 25050),
CANNOT_REMOVE_SELF_FROM_GROUP: new ApiError("This user cannot remove oneself from user group", 25051),
CANNOT_BAN_OPERATOR: new ApiError("Non-OPERATOR cannot ban OPERATOR from instance", 25052),
CANNOT_LEAVE_GUILD: new ApiError("You are not allowed to leave guilds that you joined by yourself", 25059),
EDITS_DISABLED: new ApiError("You are not allowed to edit your own messages", 25060),
DELETE_MESSAGE_DISABLED: new ApiError("You are not allowed to delete your own messages", 25061),
FEATURE_PERMANENTLY_DISABLED: new ApiError("This feature has been disabled server-side", 45006),
MISSING_RIGHTS: new ApiError("You lack rights to perform that action ({})", 50013, undefined, [""]),
CANNOT_GRANT_PERMISSIONS_EXCEEDING_RIGHTS: new ApiError("You cannot grant permissions exceeding your own rights", 50050),
ROUTES_LOOPING: new ApiError("Loops in the route definition ({})", 50060, undefined, [""]),
CANNOT_REMOVE_ROUTE: new ApiError("Cannot remove message route while it is in effect and being used", 50061),
};
/**
* The value set for a guild's default message notifications, e.g. `ALL`. Here are the available types:
* * ALL
* * MENTIONS
* * MUTED (Fosscord extension)
* @typedef {string} DefaultMessageNotifications
*/
export const DefaultMessageNotifications = ["ALL", "MENTIONS"];
export const DefaultMessageNotifications = ["ALL", "MENTIONS", "MUTED"];
/**
* The value set for a team members's membership state:
* * INVITED
* * ACCEPTED
* * INSERTED (Fosscord extension)
* @typedef {string} MembershipStates
*/
export const MembershipStates = [
// They start at 1
null,
"INSERTED",
"INVITED",
"ACCEPTED",
];
@ -755,11 +773,11 @@ export const MembershipStates = [
* The value set for a webhook's type:
* * Incoming
* * Channel Follower
* * Custom (Fosscord extension)
* @typedef {string} WebhookTypes
*/
export const WebhookTypes = [
// They start at 1
null,
"Custom",
"Incoming",
"Channel Follower",
];

View File

@ -1,6 +1,7 @@
export * from "./ApiError";
export * from "./BitField";
export * from "./Token";
//export * from "./Categories";
export * from "./cdn";
export * from "./Config";
export * from "./Constants";