import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn, Index, } from 'typeorm'; import { User } from '../../users/entities/user.entity'; export enum NotificationType { VIDEO_PROCESSING_COMPLETE = 'VIDEO_PROCESSING_COMPLETE', VIDEO_PROCESSING_FAILED = 'VIDEO_PROCESSING_FAILED', LOW_CREDITS = 'LOW_CREDITS', PAYMENT_COMPLETE = 'PAYMENT_COMPLETE', PAYMENT_FAILED = 'PAYMENT_FAILED', REFERRAL_BONUS = 'REFERRAL_BONUS', PROMO = 'PROMO', SYSTEM = 'SYSTEM', } @Entity('notifications') @Index(['userId', 'createdAt']) @Index(['userId', 'isRead']) export class Notification { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'uuid' }) userId: string; @ManyToOne(() => User) @JoinColumn({ name: 'userId' }) user: User; @Column({ type: 'enum', enum: NotificationType }) type: NotificationType; @Column({ type: 'varchar', length: 255 }) title: string; @Column({ type: 'text', nullable: true }) body: string; @Column({ type: 'boolean', default: false }) isRead: boolean; @Column({ type: 'boolean', default: false }) isPushSent: boolean; @Column({ type: 'jsonb', nullable: true }) data: Record; @CreateDateColumn() createdAt: Date; }