mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-06 10:52:31 +01:00
Partnet + Discover fix and join
This commit is contained in:
parent
5e868d431b
commit
cc492f07dc
@ -17,13 +17,13 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
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)) });
|
||||
: 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 '%COMMUNITY%'`,
|
||||
where: `"primary_category_id" = ${categories} AND "features" LIKE '%DISCOVERABLE%'`,
|
||||
take: Math.abs(Number(limit || configLimit))
|
||||
});
|
||||
total = guilds.length;
|
||||
|
@ -9,8 +9,12 @@ router.get("/categories", route({}), (req: Request, res: Response) => {
|
||||
|
||||
const { locale, primary_only } = req.query;
|
||||
|
||||
let categories;
|
||||
|
||||
let out;
|
||||
|
||||
|
||||
|
||||
switch (locale) {
|
||||
case "en-US":
|
||||
switch (primary_only) {
|
||||
|
@ -13,7 +13,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
|
||||
const 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: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || 24)) });
|
||||
res.send({ recommended_guilds: guilds });
|
||||
});
|
||||
|
||||
|
39
api/src/routes/guilds/#guild_id/discovery-requirements.ts
Normal file
39
api/src/routes/guilds/#guild_id/discovery-requirements.ts
Normal 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;
|
@ -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) => {
|
||||
|
@ -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) => {
|
||||
|
40
api/src/routes/partners/#guild_id/requirements.ts
Normal file
40
api/src/routes/partners/#guild_id/requirements.ts
Normal 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;
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user