/*
 * Copyright (c) 2022.
 * Author Peter Placzek (tada5hi)
 * For the full copyright and license information,
 * view the LICENSE file that was distributed with this source code.
 */

import {
    Column,
    CreateDateColumn,
    Entity,
    JoinColumn,
    ManyToOne,
    PrimaryGeneratedColumn,
    UpdateDateColumn
} from "typeorm";
import {AuthUser} from "../../auth/user";
import {ChatRoom} from "../room";
import {ChatMessage} from "../message";

@Entity()
export class ChatMessageStatus {
    @PrimaryGeneratedColumn("uuid")
    id!: string;

    @Column({type: "int", unsigned: true})
    last_read_id!: number;

    @ManyToOne(() => ChatMessage, { onDelete: 'CASCADE' })
    @JoinColumn({name: 'last_read_id'})
    lsat_read!: AuthUser;

    @CreateDateColumn()
    created_at!: Date;

    @UpdateDateColumn()
    updated_at!: Date;

    @Column({type: "int", unsigned: true})
    user_id!: number;

    @ManyToOne(() => AuthUser, { onDelete: 'CASCADE' })
    @JoinColumn({name: 'user_id'})
    user!: AuthUser;

    @Column({type: "varchar"})
    room_id!: string;

    @ManyToOne(() => ChatRoom, {onDelete: "CASCADE"})
    @JoinColumn({name: 'room_id'})
    room!: ChatRoom;
}
