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