summary refs log tree commit diff
path: root/api/src/routes/guilds
diff options
context:
space:
mode:
authorErkin Alp Güney <erkinalp9035@gmail.com>2022-02-16 21:16:20 +0300
committerGitHub <noreply@github.com>2022-02-16 21:16:20 +0300
commitc9fdfe196d743ecc5ca8a9ec98f1a3a436b7a20f (patch)
tree80d802d0f8f411425f6dbbf4c35c3e1bd3218b02 /api/src/routes/guilds
parentTypo (diff)
parentReturn none for dev portal + todo for categories (diff)
downloadserver-c9fdfe196d743ecc5ca8a9ec98f1a3a436b7a20f.tar.xz
Merge pull request #608 from Featyre/master
Branding updates + Fixed Discovery and custom status + Dev portal
Diffstat (limited to 'api/src/routes/guilds')
-rw-r--r--api/src/routes/guilds/#guild_id/discovery-requirements.ts39
-rw-r--r--api/src/routes/guilds/#guild_id/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/index.ts21
3 files changed, 57 insertions, 5 deletions
diff --git a/api/src/routes/guilds/#guild_id/discovery-requirements.ts b/api/src/routes/guilds/#guild_id/discovery-requirements.ts
new file mode 100644
index 00000000..ad20633f
--- /dev/null
+++ b/api/src/routes/guilds/#guild_id/discovery-requirements.ts
@@ -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;
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts
index d8ee86ff..991c3f93 100644
--- a/api/src/routes/guilds/#guild_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/index.ts
@@ -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) => {
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
index ab489743..24c74af7 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -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) => {