2019-04-07 14:50:36 +02:00
|
|
|
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
|
|
|
import { User } from './user';
|
|
|
|
import { DriveFile } from './drive-file';
|
|
|
|
import { id } from '../id';
|
2019-05-18 13:36:33 +02:00
|
|
|
import { UserGroup } from './user-group';
|
2019-04-07 14:50:36 +02: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 13:36:33 +02:00
|
|
|
...id(), nullable: true,
|
2019-04-07 14:50:36 +02:00
|
|
|
comment: 'The recipient user ID.'
|
|
|
|
})
|
2019-05-18 13:36:33 +02:00
|
|
|
public recipientId: User['id'] | null;
|
2019-04-07 14:50:36 +02:00
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public recipient: User | null;
|
|
|
|
|
2019-05-18 13:36:33 +02: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 14:50:36 +02:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 4096, nullable: true
|
|
|
|
})
|
|
|
|
public text: string | null;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isRead: boolean;
|
|
|
|
|
2019-05-18 13:36:33 +02:00
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
array: true, default: '{}'
|
|
|
|
})
|
|
|
|
public reads: User['id'][];
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
|
|
|
})
|
|
|
|
public fileId: DriveFile['id'] | null;
|
|
|
|
|
|
|
|
@ManyToOne(type => DriveFile, {
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public file: DriveFile | null;
|
|
|
|
}
|