chore: push notification test

This commit is contained in:
mahyargdz
2025-07-24 13:03:29 +03:30
parent 5f4b679467
commit 7b7167ab7d
17 changed files with 1558 additions and 12 deletions
+22
View File
@@ -8,6 +8,18 @@ import { Domain } from "../../domains/entities/domain.entity";
import { Template } from "../../templates/entities/template.entity";
import { UserRepository } from "../repositories/user.repository";
export interface WebPushSubscriptionData {
endpoint: string;
keys: {
p256dh: string;
auth: string;
};
deviceType?: string;
deviceName?: string;
registeredAt?: Date;
updatedAt?: Date;
}
@Entity({ repository: () => UserRepository })
@Unique({ properties: ["userName", "domain"], name: "unique_user_name_domain", options: { where: "deleted_at is null" } })
export class User extends BaseEntity {
@@ -51,6 +63,16 @@ export class User extends BaseEntity {
@Property({ default: true, nullable: false })
isActive: boolean & Opt;
// Push notification fields - now stores web push subscription objects
@Property({ type: "json", nullable: true })
pushTokens?: WebPushSubscriptionData[];
@Property({ type: "boolean", default: true })
pushNotificationsEnabled: boolean & Opt;
@Property({ type: "timestamptz", nullable: true })
lastPushNotificationAt?: Date;
//=========================
@OneToMany(() => RefreshToken, (token) => token.user)