summary refs log tree commit diff
path: root/src/models
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-08 16:51:45 +0200
committerGitHub <noreply@github.com>2021-04-08 16:51:45 +0200
commitc5c2af70a5c27a1bc461547a51fb3379416ccf8f (patch)
tree6cdf25485d11d7aae1a2a4efeab10e2b12ae8b86 /src/models
parentMerge branch 'main' of https://github.com/fosscord/fosscord-server-util (diff)
parentadded toBigInt and BigInt getters to bitfields (diff)
downloadserver-c5c2af70a5c27a1bc461547a51fb3379416ccf8f.tar.xz
Merge pull request #4 from notsapinho/main
added toBigInt and BigInt getters to bitfields
Diffstat (limited to 'src/models')
-rw-r--r--src/models/Channel.ts5
-rw-r--r--src/models/Guild.ts6
-rw-r--r--src/models/Role.ts4
-rw-r--r--src/models/User.ts5
4 files changed, 14 insertions, 6 deletions
diff --git a/src/models/Channel.ts b/src/models/Channel.ts

index 82ad2999..1b9a167c 100644 --- a/src/models/Channel.ts +++ b/src/models/Channel.ts
@@ -1,5 +1,6 @@ import { Schema, model, Types, Document } from "mongoose"; import db from "../util/Database"; +import toBigInt from "../util/toBigInt"; export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel {} @@ -24,8 +25,8 @@ export const ChannelSchema = new Schema({ topic: String, permission_overwrites: [ { - allow: Types.Long, - deny: Types.Long, + allow: { type: String, get: toBigInt }, + deny: { type: String, get: toBigInt }, id: String, type: Number, }, diff --git a/src/models/Guild.ts b/src/models/Guild.ts
index 819ac840..ef343010 100644 --- a/src/models/Guild.ts +++ b/src/models/Guild.ts
@@ -32,6 +32,8 @@ export interface Guild { // channels: GuildChannel[]; // * Channels are stored in a seperate collection // emojis: Emoji[]; // * Emojis are stored in a seperate collection // voice_states: []; // * voice_states are stored in a seperate collection + //TODO: + presences?: object[]; mfa_level?: number; name: string; owner_id: string; @@ -69,6 +71,7 @@ export const GuildSchema = new Schema({ max_presences: Number, max_video_channel_users: { type: Number, default: 25 }, member_count: Number, + presences: { type: [Object], default: [] }, presence_count: Number, mfa_level: Number, name: { type: String, required: true }, @@ -98,6 +101,7 @@ GuildSchema.virtual("channels", { justOne: false, autopopulate: true, }); + GuildSchema.virtual("roles", { ref: RoleModel, localField: "id", @@ -128,7 +132,7 @@ GuildSchema.virtual("joined_at", { foreignField: "guild_id", justOne: true, }).get((member: any, virtual: any, doc: any) => { - return member.joined_at; + return member?.joined_at; }); // @ts-ignore diff --git a/src/models/Role.ts b/src/models/Role.ts
index 84ad55d0..c1111c84 100644 --- a/src/models/Role.ts +++ b/src/models/Role.ts
@@ -1,5 +1,6 @@ import { Schema, model, Types, Document } from "mongoose"; import db from "../util/Database"; +import toBigInt from "../util/toBigInt"; export interface Role { id: string; @@ -28,12 +29,13 @@ export const RoleSchema = new Schema({ managed: Boolean, mentionable: Boolean, name: String, - permissions: Types.Long, + permissions: { type: String, get: toBigInt }, position: Number, tags: { bot_id: String, }, }); + RoleSchema.set("removeResponse", ["guild_id"]); // @ts-ignore diff --git a/src/models/User.ts b/src/models/User.ts
index 1f01e837..8511a9b0 100644 --- a/src/models/User.ts +++ b/src/models/User.ts
@@ -2,6 +2,7 @@ import { Activity } from "./Activity"; import { ClientStatus, Status } from "./Status"; import { Schema, Types, Document } from "mongoose"; import db from "../util/Database"; +import toBigInt from "../util/toBigInt"; export const PublicUserProjection = { username: true, @@ -141,8 +142,8 @@ export const UserSchema = new Schema({ created_at: Date, verified: Boolean, email: String, - flags: Types.Long, // TODO: automatically convert Types.Long to BitField of UserFlags - public_flags: Types.Long, + flags: { type: String, get: toBigInt }, // TODO: automatically convert Types.Long to BitField of UserFlags + public_flags: { type: String, get: toBigInt }, guilds: [String], // array of guild ids the user is part of user_data: { fingerprints: [String],