🐛 fix lean not working with virtuals
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Request, Response, Router } from "express";
|
||||
import { BanModel, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, GuildModel } from "fosscord-server-util";
|
||||
import { BanModel, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, GuildModel, toObject } from "fosscord-server-util";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { getIpAdress } from "../../../middlewares/GlobalRateLimit";
|
||||
import { BanCreateSchema } from "../../../schema/Ban";
|
||||
@@ -16,8 +16,8 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||
if (!guild) throw new HTTPError("Guild not found", 404);
|
||||
|
||||
var bans = await BanModel.find({ guild_id: guild_id }).lean().exec();
|
||||
return res.json(bans);
|
||||
var bans = await BanModel.find({ guild_id: guild_id }).exec();
|
||||
return res.json(toObject(bans));
|
||||
});
|
||||
|
||||
router.get("/:user", async (req: Request, res: Response) => {
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { Router } from "express";
|
||||
import { ChannelModel, ChannelType, GuildModel, Snowflake } from "fosscord-server-util";
|
||||
import { ChannelCreateEvent, ChannelModel, ChannelType, GuildModel, Snowflake, toObject } from "fosscord-server-util";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { ChannelModifySchema } from "../../../schema/Channel";
|
||||
import { emitEvent } from "../../../util/Event";
|
||||
import { check } from "../../../util/instanceOf";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const guild_id = (req.params.id);
|
||||
const channels = await ChannelModel.find({ guild_id }).lean().exec();
|
||||
const guild_id = req.params.id;
|
||||
const channels = await ChannelModel.find({ guild_id }).exec();
|
||||
|
||||
res.json(channels);
|
||||
res.json(toObject(channels));
|
||||
});
|
||||
|
||||
router.post("/", check(ChannelModifySchema), async (req, res) => {
|
||||
const guild_id = (req.params.id);
|
||||
const guild_id = req.params.id;
|
||||
const body = req.body as ChannelModifySchema;
|
||||
if (!body.permission_overwrites) body.permission_overwrites = [];
|
||||
if (!body.topic) body.topic = "";
|
||||
@@ -45,6 +46,8 @@ router.post("/", check(ChannelModifySchema), async (req, res) => {
|
||||
};
|
||||
await new ChannelModel(channel).save();
|
||||
|
||||
await emitEvent({ event: "CHANNEL_CREATE", data: channel, guild_id } as ChannelCreateEvent);
|
||||
|
||||
res.json(channel);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Request, Response, Router } from "express";
|
||||
import { GuildModel, MemberModel } from "fosscord-server-util";
|
||||
import { GuildModel, MemberModel, toObject } from "fosscord-server-util";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { instanceOf, Length } from "../../../util/instanceOf";
|
||||
import { PublicMemberProjection } from "../../../util/Member";
|
||||
@@ -32,10 +32,9 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
var members = await MemberModel.find({ guild_id, ...query }, PublicMemberProjection)
|
||||
.limit(limit)
|
||||
.populate({ path: "user", select: PublicUserProjection })
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
return res.json(members);
|
||||
return res.json(toObject(members));
|
||||
});
|
||||
|
||||
router.get("/:member", async (req: Request, res: Response) => {
|
||||
|
||||
Reference in New Issue
Block a user