summary refs log tree commit diff
path: root/util/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'util/src/models')
-rw-r--r--util/src/models/Activity.ts54
-rw-r--r--util/src/models/BaseClass.ts30
-rw-r--r--util/src/models/Status.ts7
-rw-r--r--util/src/models/User.ts209
-rw-r--r--util/src/models/index.ts4
5 files changed, 0 insertions, 304 deletions
diff --git a/util/src/models/Activity.ts b/util/src/models/Activity.ts
deleted file mode 100644

index 6b13477f..00000000 --- a/util/src/models/Activity.ts +++ /dev/null
@@ -1,54 +0,0 @@ -import { User } from "./User"; -import { ClientStatus, Status } from "./Status"; - -export interface Presence { - user: User; - guild_id?: string; - status: Status; - activities: Activity[]; - client_status: ClientStatus; -} - -export interface Activity { - name: string; - type: ActivityType; - url?: string; - created_at?: Date; - timestamps?: { - start?: number; - end?: number; - }[]; - application_id?: string; - details?: string; - state?: string; - emoji?: { - name: string; - id?: string; - amimated?: boolean; - }; - party?: { - id?: string; - size?: [number, number]; - }; - assets?: { - large_image?: string; - large_text?: string; - small_image?: string; - small_text?: string; - }; - secrets?: { - join?: string; - spectate?: string; - match?: string; - }; - instance?: boolean; - flags?: bigint; -} - -export enum ActivityType { - GAME = 0, - STREAMING = 1, - LISTENING = 2, - CUSTOM = 4, - COMPETING = 5, -} diff --git a/util/src/models/BaseClass.ts b/util/src/models/BaseClass.ts deleted file mode 100644
index d4f635f6..00000000 --- a/util/src/models/BaseClass.ts +++ /dev/null
@@ -1,30 +0,0 @@ -import "reflect-metadata"; -import { BaseEntity, BeforeInsert, BeforeUpdate, Column, PrimaryGeneratedColumn } from "typeorm"; -import { Snowflake } from "../util/Snowflake"; -import { IsString, validateOrReject } from "class-validator"; - -export class BaseClass extends BaseEntity { - @PrimaryGeneratedColumn() - @Column() - @IsString() - id: string; - - constructor(props?: any, opts: { id?: string } = {}) { - super(); - this.id = opts.id || Snowflake.generate(); - Object.defineProperties(this, props); - } - - @BeforeUpdate() - @BeforeInsert() - async validate() { - await validateOrReject(this, {}); - } -} - -// @ts-ignore -global.BaseClass = BaseClass; - -var test = new BaseClass({}); - -setTimeout(() => {}, 10000 * 1000); diff --git a/util/src/models/Status.ts b/util/src/models/Status.ts deleted file mode 100644
index c4dab586..00000000 --- a/util/src/models/Status.ts +++ /dev/null
@@ -1,7 +0,0 @@ -export type Status = "idle" | "dnd" | "online" | "offline"; - -export interface ClientStatus { - desktop?: string; // e.g. Windows/Linux/Mac - mobile?: string; // e.g. iOS/Android - web?: string; // e.g. browser, bot account -} diff --git a/util/src/models/User.ts b/util/src/models/User.ts deleted file mode 100644
index 27aa63d1..00000000 --- a/util/src/models/User.ts +++ /dev/null
@@ -1,209 +0,0 @@ -import { Column, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; -import { Activity } from "./Activity"; -import { BaseClass } from "./BaseClass"; -import { ClientStatus, Status } from "./Status"; -import { validateOrReject, IsInt, IsEmail, IsPhoneNumber, IsBoolean, IsString, ValidateNested } from "class-validator"; - -export const PublicUserProjection = { - username: true, - discriminator: true, - id: true, - public_flags: true, - avatar: true, - accent_color: true, - banner: true, - bio: true, - bot: true, -}; - -export class User extends BaseClass { - @Column() - @IsString() - username: string; // username max length 32, min 2 (should be configurable) - - @Column() - @IsInt() - discriminator: string; // #0001 4 digit long string from #0001 - #9999 - - @Column() - @IsString() - avatar: string | null; // hash of the user avatar - - @Column() - @IsInt() - accent_color: number | null; // banner color of user - - @Column() - banner: string | null; // hash of the user banner - - @Column() - @IsPhoneNumber() - phone: string | null; // phone number of the user - - @Column() - @IsBoolean() - desktop: boolean; // if the user has desktop app installed - - @Column() - @IsBoolean() - mobile: boolean; // if the user has mobile app installed - - @Column() - @IsBoolean() - premium: boolean; // if user bought nitro - - @Column() - premium_type: number; // nitro level - - @Column() - @IsBoolean() - bot: boolean; // if user is bot - - @Column() - bio: string; // short description of the user (max 190 chars -> should be configurable) - - @Column() - @IsBoolean() - system: boolean; // shouldn't be used, the api sents this field type true, if the generated message comes from a system generated author - - @Column() - @IsBoolean() - nsfw_allowed: boolean; // if the user is older than 18 (resp. Config) - - @Column() - @IsBoolean() - mfa_enabled: boolean; // if multi factor authentication is enabled - - @Column() - created_at: Date; // registration date - - @Column() - @IsBoolean() - verified: boolean; // if the user is offically verified - - @Column() - @IsBoolean() - disabled: boolean; // if the account is disabled - - @Column() - @IsBoolean() - deleted: boolean; // if the user was deleted - - @Column() - @IsEmail() - email: string | null; // email of the user - - @Column() - flags: bigint; // UserFlags - - @Column() - public_flags: bigint; - - @Column("simple-array") // string in simple-array must not contain commas - @IsString({ each: true }) - guilds: string[]; // array of guild ids the user is part of - - @Column("simple-json") - @ValidateNested() // TODO: https://github.com/typestack/class-validator#validating-nested-objects - user_data: { - valid_tokens_since: Date; // all tokens with a previous issue date are invalid - hash: string; // hash of the password, salt is saved in password (bcrypt) - fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts - }; - - @Column("simple-json") - @ValidateNested() // TODO: https://github.com/typestack/class-validator#validating-nested-objects - presence: { - status: Status; - activities: Activity[]; - client_status: ClientStatus; - }; - - @Column("simple-json") - @ValidateNested() // TODO: https://github.com/typestack/class-validator#validating-nested-objects - relationships: { - id: string; - nickname?: string; - type: RelationshipType; - }[]; - - @Column("simple-json") - @ValidateNested() // TODO: https://github.com/typestack/class-validator#validating-nested-objects - connected_accounts: { - access_token: string; - friend_sync: boolean; - id: string; - name: string; - revoked: boolean; - show_activity: boolean; - type: string; - verifie: boolean; - visibility: number; - }[]; - - @Column("simple-json") - @ValidateNested() // TODO: https://github.com/typestack/class-validator#validating-nested-objects - user_settings: { - afk_timeout: number; - allow_accessibility_detection: boolean; - animate_emoji: boolean; - animate_stickers: number; - contact_sync_enabled: boolean; - convert_emoticons: boolean; - custom_status: { - emoji_id: string | null; - emoji_name: string | null; - expires_at: number | null; - text: string | null; - }; - default_guilds_restricted: boolean; - detect_platform_accounts: boolean; - developer_mode: boolean; - disable_games_tab: boolean; - enable_tts_command: boolean; - explicit_content_filter: number; - friend_source_flags: { all: boolean }; - gateway_connected: boolean; - gif_auto_play: boolean; - guild_folders: // every top guild is displayed as a "folder" - { - color: number; - guild_ids: string[]; - id: number; - name: string; - }[]; - guild_positions: string[]; // guild ids ordered by position - inline_attachment_media: boolean; - inline_embed_media: boolean; - locale: string; // en_US - message_display_compact: boolean; - native_phone_integration_enabled: boolean; - render_embeds: boolean; - render_reactions: boolean; - restricted_guilds: string[]; - show_current_game: boolean; - status: "online" | "offline" | "dnd" | "idle"; - stream_notifications_enabled: boolean; - theme: "dark" | "white"; // dark - timezone_offset: number; // e.g -60 - }; -} - -// Private user data that should never get sent to the client -export interface PublicUser { - id: string; - discriminator: string; - username: string; - avatar: string | null; - accent_color: number; - banner: string | null; - public_flags: bigint; - bot: boolean; -} - -export enum RelationshipType { - outgoing = 4, - incoming = 3, - blocked = 2, - friends = 1, -} diff --git a/util/src/models/index.ts b/util/src/models/index.ts deleted file mode 100644
index 94882a0a..00000000 --- a/util/src/models/index.ts +++ /dev/null
@@ -1,4 +0,0 @@ -export * from "./Activity"; -export * from "./BaseClass"; -export * from "./Status"; -export * from "./User";