summary refs log tree commit diff
diff options
context:
space:
mode:
authorFeatyre <twooter.0g179@simplelogin.co>2022-01-24 07:21:48 +0000
committerFeatyre <twooter.0g179@simplelogin.co>2022-01-24 07:21:48 +0000
commite3f20f849d089493328314ad7d7518eaea3d862a (patch)
tree294774d318a7baf80f271e71a4346d26523f432d
parentMerge branch 'fosscord:master' into master (diff)
downloadserver-e3f20f849d089493328314ad7d7518eaea3d862a.tar.xz
category + discovery + custom status fix, new config
-rw-r--r--api/assets/fosscord-login.css1
-rw-r--r--api/src/routes/discoverable-guilds.ts29
-rw-r--r--api/src/routes/discovery.ts (renamed from api/src/routes/categories.ts)4
-rw-r--r--api/src/routes/guild-recommendations.ts2
-rw-r--r--bundle/package-lock.json6
-rw-r--r--bundle/package.json2
-rw-r--r--gateway/package.json2
-rw-r--r--util/src/entities/Config.ts16
-rw-r--r--util/src/entities/Guild.ts2
-rw-r--r--util/src/entities/User.ts9
10 files changed, 39 insertions, 34 deletions
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 a4559b59..8b7d343f 100644
--- a/api/src/routes/discoverable-guilds.ts
+++ b/api/src/routes/discoverable-guilds.ts
@@ -6,26 +6,29 @@ import { route } from "@fosscord/api";
 const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
-	const { limit, categories } = req.query;
-	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)) });
 	let guilds;
 	let total;
-	switch (categories) {
-		case "1":
-			guilds = showAllGuilds
-				? await Guild.find({ take: Math.abs(Number(limit || 24)) })
-				: await Guild.find({ where: `"primary_category_id" = 1 AND "features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 24)) });
-			total = guilds.length;
-		default:
-			guilds = showAllGuilds
-				? await Guild.find({ take: Math.abs(Number(limit || 24)) })
-				: await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 24)) });
+	if (categories == undefined) {
+		guilds = showAllGuilds
+			? await Guild.find({ take: Math.abs(Number(limit || configLimit)) })
+			: await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, 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 '%COMMUNITY%'`,
+						take: Math.abs(Number(limit || configLimit))
+				  });
 			total = guilds.length;
 	}
-	res.send({ total: total, guilds: guilds, offset: 0, limit: limit});
+	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/categories.ts b/api/src/routes/discovery.ts
index 58322676..067dd442 100644
--- a/api/src/routes/categories.ts
+++ b/api/src/routes/discovery.ts
@@ -3,7 +3,7 @@ import { route } from "@fosscord/api";
 
 const router = Router();
 
-router.get("/", route({}), (req: Request, res: Response) => {
+router.get("/categories", route({}), (req: Request, res: Response) => {
 	// TODO:
 	// Load categories from db instead
 
@@ -21,7 +21,7 @@ router.get("/", route({}), (req: Request, res: Response) => {
 				}
 	}
 
-	res.json(out).status(200);
+	res.send(out);
 });
 
 export default router;
diff --git a/api/src/routes/guild-recommendations.ts b/api/src/routes/guild-recommendations.ts
index 47017a6f..ecc5e546 100644
--- a/api/src/routes/guild-recommendations.ts
+++ b/api/src/routes/guild-recommendations.ts
@@ -7,7 +7,7 @@ const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { limit, personalization_disabled } = req.query;
-	var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery;
+	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)) });
diff --git a/bundle/package-lock.json b/bundle/package-lock.json
index d026e7c7..573d4059 100644
--- a/bundle/package-lock.json
+++ b/bundle/package-lock.json
@@ -46,7 +46,7 @@
 				"morgan": "^1.10.0",
 				"multer": "^1.4.2",
 				"nanocolors": "^0.2.12",
-				"node-fetch": "^2.6.7",
+				"node-fetch": "^2.6.2",
 				"node-os-utils": "^1.3.5",
 				"patch-package": "^6.4.7",
 				"pg": "^8.7.1",
@@ -213,7 +213,7 @@
 				"jsonwebtoken": "^8.5.1",
 				"lambert-server": "^1.2.11",
 				"missing-native-js-functions": "^1.2.18",
-				"node-fetch": "^3.1.1",
+				"node-fetch": "^2.6.2",
 				"proxy-agent": "^5.0.0",
 				"typeorm": "^0.2.37",
 				"ws": "^7.4.2"
@@ -13377,7 +13377,7 @@
 				"jsonwebtoken": "^8.5.1",
 				"lambert-server": "^1.2.11",
 				"missing-native-js-functions": "^1.2.18",
-				"node-fetch": "^3.1.1",
+				"node-fetch": "^2.6.2",
 				"proxy-agent": "^5.0.0",
 				"ts-node-dev": "^1.1.6",
 				"ts-patch": "^1.4.4",
diff --git a/bundle/package.json b/bundle/package.json
index 071a4899..75827521 100644
--- a/bundle/package.json
+++ b/bundle/package.json
@@ -91,7 +91,7 @@
 		"missing-native-js-functions": "^1.2.18",
 		"morgan": "^1.10.0",
 		"multer": "^1.4.2",
-		"node-fetch": "^2.6.7",
+		"node-fetch": "^2.6.2",
 		"node-os-utils": "^1.3.5",
 		"patch-package": "^6.4.7",
 		"pg": "^8.7.1",
diff --git a/gateway/package.json b/gateway/package.json
index 7daddfc0..6d0d2d1c 100644
--- a/gateway/package.json
+++ b/gateway/package.json
@@ -32,7 +32,7 @@
 		"jsonwebtoken": "^8.5.1",
 		"lambert-server": "^1.2.11",
 		"missing-native-js-functions": "^1.2.18",
-		"node-fetch": "^3.1.1",
+		"node-fetch": "^2.6.2",
 		"proxy-agent": "^5.0.0",
 		"typeorm": "^0.2.37",
 		"ws": "^7.4.2"
diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts
index 4da65b36..f4a266dc 100644
--- a/util/src/entities/Config.ts
+++ b/util/src/entities/Config.ts
@@ -157,8 +157,12 @@ export interface ConfigValue {
 		available: Region[];
 	};
 	guild: {
-		showAllGuildsInDiscovery: boolean;
-		homeDiscoveryUseRecommendation: boolean; // TODO: Recommendation, privacy concern?
+		discovery: {
+			showAllGuilds: boolean;
+			useRecommendation: boolean; // TODO: Recommendation, privacy concern?
+			offset: number;
+			limit: number;
+		};
 		autoJoin: {
 			enabled: boolean;
 			guilds: string[];
@@ -354,8 +358,12 @@ export const DefaultConfigOptions: ConfigValue = {
 		],
 	},
 	guild: {
-		showAllGuildsInDiscovery: false,
-		homeDiscoveryUseRecommendation: false,
+		discovery: {
+			showAllGuilds: false,
+			useRecommendation: false,
+			offset: 0,
+			limit: 24,
+		},
 		autoJoin: {
 			enabled: true,
 			canLeave: true,
diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts
index 65ba2ae2..18fa7a0a 100644
--- a/util/src/entities/Guild.ts
+++ b/util/src/entities/Guild.ts
@@ -287,7 +287,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: 0,
+			primary_category_id: null,
 			id: guild_id,
 			max_members: 250000,
 			max_presences: 250000,
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts
index 5f2618e0..1027331a 100644
--- a/util/src/entities/User.ts
+++ b/util/src/entities/User.ts
@@ -289,12 +289,7 @@ export const defaultSettings: UserSettings = {
 	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,
@@ -334,7 +329,7 @@ export interface UserSettings {
 		emoji_name?: string;
 		expires_at?: number;
 		text?: string;
-	};
+	} | null;
 	default_guilds_restricted: boolean;
 	detect_platform_accounts: boolean;
 	developer_mode: boolean;