Skip to content

Domain Model

Signal không định nghĩa schema riêng. Entity được lưu duy nhất của nó là ActivityNotification, mà bảng, model, và repository đều nằm trong @nx/core. Trạng thái kết nối và khoá AES được giữ in-memory theo từng instance và không được mô hình hoá ở đây.

1. ERD đầy đủ

ActivityNotification không có relation foreign-key nào trong schema — recipientIdorganizerId là soft reference tới ID user / organizer được giải lúc ghi.

2. Entities

ActivityNotification

Thuộc tínhGiá trị
TableActivityNotification
Sourcepackages/core/src/models/schemas/public/activity-notification/schema.ts
Modelpackages/core/src/models/schemas/public/activity-notification/model.ts
RepositoryActivityNotificationRepository (@nx/core)
Soft-deletecó (SoftDeletableRepository, deletedAt)
Owner ID columnrecipientId (theo từng user)

Trường:

TrườngKiểuBắt buộcMặc địnhMô tả
idtextSnowflakePrimary key
recipientIdtextUser đích; một hàng mỗi người nhận
typevarchar(80)TActivityNotificationTypes (xem enum)
organizerIdtextnullOrganizer sở hữu, nếu có phạm vi
contenttextNội dung plain-text đã render
htmltextNội dung HTML đã render
actionUrltextnullĐích deep-link
datajsonb{}Snapshot payload actor + sự kiện
isReadbooleanfalseCờ đã đọc
readAttimestamptznullĐặt khi đánh dấu đã đọc

Enum type (ActivityNotificationTypes):

Giá trịMô tả
PAYMENT_SUCCESSLoại duy nhất hiện thực hôm nay; render từ payload actor + payment

Worker từ chối bất kỳ eventType nào không trong ActivityNotificationTypes.SCHEME_SET (log cảnh báo và bỏ qua).

Index:

TênCộtMục đích
IDX_ActivityNotification_recipientId_isDeleted_createdAtrecipient_id, deleted_at, created_atQuery chuông — notification của người nhận, mới nhất trước
IDX_ActivityNotification_recipientId_isReadrecipient_id, is_readĐếm chưa đọc
IDX_ActivityNotification_organizerId_type_createdAtorganizer_id, type, created_atLọc theo organizer + type

Relations: không khai báo trong schema (recipientId / organizerId là soft reference).

3. Bất biến xuyên entity

Bất biếnCách thực thi
Một hàng mỗi người nhận mỗi fan-outWorker lặp qua người nhận đã giải và createAll một hàng mỗi cái
readAt đặt ⇔ isRead = trueActivityNotificationService.markAsRead / markAllAsRead đặt cả hai cùng nhau
Người nhận chỉ đọc/sửa hàng của chính họController scope mọi query theo recipientId = subject JWT

4. Hành vi Soft-delete

Hành viChi tiết
Mặc định đọcdeletedAt IS NULL (defaultFilter của model)
Hard-deletesignal không dùng
Restorekhông expose

5. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.