2019-04-07 07:50:36 -05:00
|
|
|
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
2021-08-19 07:55:45 -05:00
|
|
|
import { User } from './user';
|
|
|
|
import { DriveFile } from './drive-file';
|
|
|
|
import { id } from '../id';
|
|
|
|
import { UserGroup } from './user-group';
|
2019-04-07 07:50:36 -05:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class MessagingMessage {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The created date of the MessagingMessage.'
|
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
comment: 'The sender user ID.'
|
|
|
|
})
|
|
|
|
public userId: User['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public user: User | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
2019-05-18 06:36:33 -05:00
|
|
|
...id(), nullable: true,
|
2019-04-07 07:50:36 -05:00
|
|
|
comment: 'The recipient user ID.'
|
|
|
|
})
|
2019-05-18 06:36:33 -05:00
|
|
|
public recipientId: User['id'] | null;
|
2019-04-07 07:50:36 -05:00
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public recipient: User | null;
|
|
|
|
|
2019-05-18 06:36:33 -05:00
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(), nullable: true,
|
|
|
|
comment: 'The recipient group ID.'
|
|
|
|
})
|
|
|
|
public groupId: UserGroup['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => UserGroup, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public group: UserGroup | null;
|
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 4096, nullable: true
|
|
|
|
})
|
|
|
|
public text: string | null;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isRead: boolean;
|
|
|
|
|
2019-12-14 12:37:19 -06:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
|
|
|
})
|
|
|
|
public uri: string | null;
|
|
|
|
|
2019-05-18 06:36:33 -05:00
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
array: true, default: '{}'
|
|
|
|
})
|
|
|
|
public reads: User['id'][];
|
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
|
|
|
})
|
|
|
|
public fileId: DriveFile['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => DriveFile, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public file: DriveFile | null;
|
|
|
|
}
|