1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

🔒 fix exposing user in channel.recipients

This commit is contained in:
Flam3rboy 2021-08-08 00:27:23 +02:00
parent 762255aad0
commit c73cab2d03
2 changed files with 4 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import { Schema, model, Types, Document } from "mongoose"; import { Schema, model, Types, Document } from "mongoose";
import db from "../util/Database"; import db from "../util/Database";
import toBigInt from "../util/toBigInt"; import toBigInt from "../util/toBigInt";
import { UserModel } from "./User"; import { PublicUserProjection, UserModel } from "./User";
// @ts-ignore // @ts-ignore
export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel { export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel {
@ -42,7 +42,7 @@ ChannelSchema.virtual("recipients", {
localField: "recipient_ids", localField: "recipient_ids",
foreignField: "id", foreignField: "id",
justOne: false, justOne: false,
autopopulate: true, autopopulate: { select: PublicUserProjection },
}); });
ChannelSchema.set("removeResponse", ["recipient_ids"]); ChannelSchema.set("removeResponse", ["recipient_ids"]);

View File

@ -1,7 +1,7 @@
import { Schema, Document, Types } from "mongoose"; import { Schema, Document, Types } from "mongoose";
import db from "../util/Database"; import db from "../util/Database";
import { ChannelModel } from "./Channel"; import { ChannelModel } from "./Channel";
import { UserModel } from "./User"; import { PublicUserProjection, UserModel } from "./User";
import { GuildModel } from "./Guild"; import { GuildModel } from "./Guild";
export interface Invite { export interface Invite {
@ -60,13 +60,7 @@ InviteSchema.virtual("inviter", {
foreignField: "id", foreignField: "id",
justOne: true, justOne: true,
autopopulate: { autopopulate: {
select: { select: PublicUserProjection,
id: true,
username: true,
avatar: true,
discriminater: true,
public_flags: true,
},
}, },
}); });