mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-06 10:52:31 +01:00
category + discovery + custom status fix, new config
This commit is contained in:
parent
ba70cf4b97
commit
e3f20f849d
@ -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 */
|
||||
|
@ -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":
|
||||
if (categories == undefined) {
|
||||
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)) });
|
||||
? 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;
|
||||
default:
|
||||
} else {
|
||||
guilds = showAllGuilds
|
||||
? await Guild.find({ take: Math.abs(Number(limit || 24)) })
|
||||
: await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 24)) });
|
||||
? 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;
|
||||
|
@ -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;
|
@ -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)) });
|
||||
|
6
bundle/package-lock.json
generated
6
bundle/package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user