mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 20:31:45 +00:00
- Add FCM token registration during login/signup - Implement transaction notification listeners - Add notification data column to database - Update Firebase service with data payload support - Add transaction notification scopes - Update card repository to load relations for notifications
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { User } from '~/user/entities';
|
|
import { NotificationChannel, NotificationScope, NotificationStatus } from '../enums';
|
|
|
|
@Entity('notifications')
|
|
export class Notification {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column('varchar', { name: 'title' })
|
|
title!: string;
|
|
|
|
@Column('varchar', { name: 'message' })
|
|
message!: string;
|
|
|
|
@Column('varchar', { name: 'recipient', nullable: true })
|
|
recipient?: string | null;
|
|
|
|
@Column('varchar', { name: 'scope' })
|
|
scope!: NotificationScope;
|
|
|
|
@Column('varchar', { name: 'status', nullable: true })
|
|
status!: NotificationStatus | null;
|
|
|
|
@Column('varchar', { name: 'channel' })
|
|
channel!: NotificationChannel;
|
|
|
|
@Column('uuid', { name: 'user_id', nullable: true })
|
|
userId!: string;
|
|
|
|
@Column('jsonb', { name: 'data', nullable: true })
|
|
data?: Record<string, any>;
|
|
|
|
@ManyToOne(() => User, (user) => user.notifications, { onDelete: 'CASCADE', nullable: true })
|
|
@JoinColumn({ name: 'user_id' })
|
|
user!: User;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
}
|