Implemented DMs and group DMs

This commit is contained in:
AlTech98
2021-09-16 21:33:36 +02:00
parent 0506d40aa1
commit d630f09f80
19 changed files with 342 additions and 79 deletions
+8 -7
View File
@@ -1,7 +1,6 @@
import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, RelationId } from "typeorm";
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild";
import { Message } from "./Message";
import { User } from "./User";
import { HTTPError } from "lambert-server";
import { emitEvent, getPermission, Snowflake } from "../util";
@@ -31,6 +30,9 @@ export class Channel extends BaseClass {
@Column({ nullable: true })
name?: string;
@Column({ nullable: true })
icon?: string;
@Column({ type: "simple-enum", enum: ChannelType })
type: ChannelType;
@@ -38,13 +40,8 @@ export class Channel extends BaseClass {
recipients?: Recipient[];
@Column({ nullable: true })
@RelationId((channel: Channel) => channel.last_message)
last_message_id: string;
@JoinColumn({ name: "last_message_id" })
@ManyToOne(() => Message)
last_message?: Message;
@Column({ nullable: true })
@RelationId((channel: Channel) => channel.guild)
guild_id?: string;
@@ -162,6 +159,10 @@ export class Channel extends BaseClass {
return channel;
}
isDm() {
return this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM
}
}
export interface ChannelPermissionOverwrite {
+3
View File
@@ -19,5 +19,8 @@ export class Recipient extends BaseClass {
@ManyToOne(() => require("./User").User)
user: import("./User").User;
@Column({ default: false })
closed: boolean;
// TODO: settings/mute/nick/added at/encryption keys/read_state
}
+1 -1
View File
@@ -124,7 +124,7 @@ export class User extends BaseClass {
flags: string; // UserFlags
@Column()
public_flags: string;
public_flags: number;
@JoinColumn({ name: "relationship_ids" })
@OneToMany(() => Relationship, (relationship: Relationship) => relationship.from)