diff --git a/api/assets/fosscord-login.css b/api/assets/fosscord-login.css
index 34cf542b..d507c545 100644
--- a/api/assets/fosscord-login.css
+++ b/api/assets/fosscord-login.css
@@ -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 */
diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts
index 1cf56f84..df4448df 100644
--- a/api/src/routes/discoverable-guilds.ts
+++ b/api/src/routes/discoverable-guilds.ts
@@ -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;
+ let total;
+ 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)) });
+ total = guilds.length;
+ } 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))
+ });
+ total = guilds.length;
+ }
+ res.send({ total: total, guilds: guilds, offset: Number(offset || Config.get().guild.discovery.offset), limit: Number(limit || configLimit) });
});
export default router;
diff --git a/api/src/routes/discovery.ts b/api/src/routes/discovery.ts
index bc495d42..b6a25a13 100644
--- a/api/src/routes/discovery.ts
+++ b/api/src/routes/discovery.ts
@@ -5,8 +5,27 @@ const router = Router();
router.get("/categories", route({}), (req: Request, res: Response) => {
// TODO:
- //const { locale, primary_only } = req.query;
- res.json([]).status(200);
+ // Load categories from db instead of hardcoding
+
+ const { locale, primary_only } = req.query;
+
+ let categories;
+
+ let out;
+
+
+
+ switch (locale) {
+ case "en-US":
+ switch (primary_only) {
+ case "false":
+ out = [{"id": 0, "is_primary": true, "name": "General"}, {"id": 10, "is_primary": true, "name": "Travel & Food"}, {"id": 15, "is_primary": false, "name": "Esports"}, {"id": 30, "is_primary": false, "name": "LFG"}, {"id": 32, "is_primary": false, "name": "Theorycraft"}, {"id": 36, "is_primary": false, "name": "Business"}, {"id": 39, "is_primary": false, "name": "Fandom"}, {"id": 43, "is_primary": true, "name": "Emoji"}, {"id": 18, "is_primary": false, "name": "Books"}, {"id": 23, "is_primary": false, "name": "Podcasts"}, {"id": 28, "is_primary": false, "name": "Investing"}, {"id": 7, "is_primary": true, "name": "Sports"}, {"id": 13, "is_primary": true, "name": "Other"}, {"id": 2, "is_primary": true, "name": "Music"}, {"id": 3, "is_primary": true, "name": "Entertainment"}, {"id": 4, "is_primary": true, "name": "Creative Arts"}, {"id": 6, "is_primary": true, "name": "Education"}, {"id": 9, "is_primary": true, "name": "Relationships & Identity"}, {"id": 11, "is_primary": true, "name": "Fitness & Health"}, {"id": 12, "is_primary": true, "name": "Finance"}, {"id": 45, "is_primary": false, "name": "Mobile"}, {"id": 16, "is_primary": false, "name": "Anime & Manga"}, {"id": 17, "is_primary": false, "name": "Movies & TV"}, {"id": 19, "is_primary": false, "name": "Art"}, {"id": 20, "is_primary": false, "name": "Writing"}, {"id": 22, "is_primary": false, "name": "Programming"}, {"id": 25, "is_primary": false, "name": "Memes"}, {"id": 27, "is_primary": false, "name": "Cryptocurrency"}, {"id": 31, "is_primary": false, "name": "Customer Support"}, {"id": 33, "is_primary": false, "name": "Events"}, {"id": 34, "is_primary": false, "name": "Roleplay"}, {"id": 37, "is_primary": false, "name": "Local Group"}, {"id": 38, "is_primary": false, "name": "Collaboration"}, {"id": 40, "is_primary": false, "name": "Wiki & Guide"}, {"id": 42, "is_primary": false, "name": "Subreddit"}, {"id": 1, "is_primary": true, "name": "Gaming"}, {"id": 5, "is_primary": true, "name": "Science & Tech"}, {"id": 8, "is_primary": true, "name": "Fashion & Beauty"}, {"id": 14, "is_primary": true, "name": "General Chatting"}, {"id": 21, "is_primary": false, "name": "Crafts, DIY, & Making"}, {"id": 48, "is_primary": false, "name": "Game Developer"}, {"id": 49, "is_primary": true, "name": "Bots"}, {"id": 24, "is_primary": false, "name": "Tabletop Games"}, {"id": 26, "is_primary": false, "name": "News & Current Events"}, {"id": 29, "is_primary": false, "name": "Studying & Teaching"}, {"id": 35, "is_primary": false, "name": "Content Creator"}, {"id": 44, "is_primary": false, "name": "Comics & Cartoons"}, {"id": 46, "is_primary": false, "name": "Console"}, {"id": 47, "is_primary": false, "name": "Charity & Nonprofit"}]
+ case "true":
+ out = [{"id": 0, "is_primary": true, "name": "General"}, {"id": 10, "is_primary": true, "name": "Travel & Food"}, {"id": 43, "is_primary": true, "name": "Emoji"}, {"id": 7, "is_primary": true, "name": "Sports"}, {"id": 13, "is_primary": true, "name": "Other"}, {"id": 2, "is_primary": true, "name": "Music"}, {"id": 3, "is_primary": true, "name": "Entertainment"}, {"id": 4, "is_primary": true, "name": "Creative Arts"}, {"id": 6, "is_primary": true, "name": "Education"}, {"id": 9, "is_primary": true, "name": "Relationships & Identity"}, {"id": 11, "is_primary": true, "name": "Fitness & Health"}, {"id": 12, "is_primary": true, "name": "Finance"}, {"id": 1, "is_primary": true, "name": "Gaming"}, {"id": 5, "is_primary": true, "name": "Science & Tech"}, {"id": 8, "is_primary": true, "name": "Fashion & Beauty"}, {"id": 14, "is_primary": true, "name": "General Chatting"}]
+ }
+ }
+
+ res.send(out);
});
export default router;
diff --git a/api/src/routes/guild-recommendations.ts b/api/src/routes/guild-recommendations.ts
index 503b19b7..3e5b8f32 100644
--- a/api/src/routes/guild-recommendations.ts
+++ b/api/src/routes/guild-recommendations.ts
@@ -6,14 +6,14 @@ 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 guilds = showAllGuilds
- ? await Guild.find({ take: Math.abs(Number(limit || 20)) })
- : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 100)) });
+ ? 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 });
});
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..18a6ed4b 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 } });
+
+ res.send({...guild, emojis: emoji, roles: roles, stickers: stickers});
await Member.addToGuild(member_id, guild_id);
- res.sendStatus(204);
});
router.delete("/", route({ permission: "KICK_MEMBERS" }), async (req: Request, res: Response) => {
diff --git a/api/src/routes/partners/#guild_id/requirements.ts b/api/src/routes/partners/#guild_id/requirements.ts
new file mode 100644
index 00000000..545c5c78
--- /dev/null
+++ b/api/src/routes/partners/#guild_id/requirements.ts
@@ -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;
diff --git a/api/src/util/handlers/route.ts b/api/src/util/handlers/route.ts
index 05658ad3..0048c4dd 100644
--- a/api/src/util/handlers/route.ts
+++ b/api/src/util/handlers/route.ts
@@ -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);
|