🎨 rename recipients -> recipient_ids

This commit is contained in:
Flam3rboy 2021-05-31 20:32:50 +02:00
parent 24a7accc16
commit 0713f89bba
2 changed files with 9 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import { UserModel } from "./User";
// @ts-ignore // @ts-ignore
export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel { export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel {
recipients: null | string[]; recipient_ids: null | string[];
} }
export interface ChannelDocument extends Document, AnyChannel { export interface ChannelDocument extends Document, AnyChannel {
@ -44,6 +44,9 @@ ChannelSchema.virtual("recipients", {
justOne: false, justOne: false,
autopopulate: true, autopopulate: true,
}); });
ChannelSchema.set("removeResponse", ["recipient_ids"]);
// @ts-ignore // @ts-ignore
export const ChannelModel = db.model<ChannelDocument>("Channel", ChannelSchema, "channels"); export const ChannelModel = db.model<ChannelDocument>("Channel", ChannelSchema, "channels");

View File

@ -145,7 +145,7 @@ export class Permissions extends BitField {
guild: { roles: Role[] }; guild: { roles: Role[] };
channel?: { channel?: {
overwrites?: ChannelPermissionOverwrite[]; overwrites?: ChannelPermissionOverwrite[];
recipients?: string[] | null; recipient_ids?: string[] | null;
owner_id?: string; owner_id?: string;
}; };
}) { }) {
@ -163,9 +163,9 @@ export class Permissions extends BitField {
permission = Permissions.channelPermission(overwrites, permission); permission = Permissions.channelPermission(overwrites, permission);
} }
if (channel?.recipients) { if (channel?.recipient_ids) {
if (channel?.owner_id === user.id) return new Permissions("ADMINISTRATOR"); if (channel?.owner_id === user.id) return new Permissions("ADMINISTRATOR");
if (channel.recipients.includes(user.id)) { if (channel.recipient_ids.includes(user.id)) {
// Default dm permissions // Default dm permissions
return new Permissions([ return new Permissions([
"VIEW_CHANNEL", "VIEW_CHANNEL",
@ -210,7 +210,7 @@ export async function getPermission(
if (channel_id && !channel) { if (channel_id && !channel) {
channel = await ChannelModel.findOne( channel = await ChannelModel.findOne(
{ id: channel_id }, { id: channel_id },
{ permission_overwrites: true, recipients: true, owner_id: true, guild_id: true } { permission_overwrites: true, recipient_ids: true, owner_id: true, guild_id: true }
).exec(); ).exec();
if (!channel) throw new HTTPError("Channel not found", 404); if (!channel) throw new HTTPError("Channel not found", 404);
if (channel.guild_id) guild_id = channel.guild_id; if (channel.guild_id) guild_id = channel.guild_id;
@ -238,7 +238,7 @@ export async function getPermission(
channel: { channel: {
overwrites: channel?.permission_overwrites, overwrites: channel?.permission_overwrites,
owner_id: channel?.owner_id, owner_id: channel?.owner_id,
recipients: channel?.recipients, recipient_ids: channel?.recipient_ids,
}, },
}); });