sync/identity/2026-09-24-be-notification-entity-link-async-email.md · Xem trên GitHub

Notification có entityType/entityId; email gửi bất đồng bộ

Đã đóng normal feature
Module
identity
Từ
BE
Người raise
ThaiThanhLuan
Ngày tạo
2026-09-24
Refs
IDENTITY-023
Bên nhận
FE appliedMobile n/a

Tóm tắt

Thông báo giờ có thể trỏ tới đối tượng nguồn (entityType + entityId), để FE mở đúng trang khi người dùng bấm vào thông báo. Wework/Workflow/Request sẽ bắt đầu sinh thông báo thật qua outbox (các ticket REQUEST-021, WEWORK-029, WORKFLOW-006 làm tiếp). Email của thông báo được gửi nền, không còn trong request POST /notifications.

Chi tiết

  • Thêm 2 field nullable vào object Notification ở mọi response có trả nó: entityType: string | null, entityId: string | null. Thông báo tạo tay qua POST /notifications và thông báo cũ có cả 2 là null.
  • Giá trị entityType dự kiến (theo các ticket đang làm): request (id = request id), wework_task (id = task wework), workflow_task (id = task workflow). Sẽ ghi chính xác trong sync note của từng ticket.
  • POST /notifications không gửi email trong request nữa: email được xếp hàng và worker ở identity gửi sau vài giây. Response không đổi.
  • Thông báo từ các module khác xuất hiện sau khi worker chạy (mặc định mỗi 5 giây) — không tức thì.

Contract (trước → sau)

Trước Sau
Endpoint GET /notifications, PATCH /notifications/:id/read, POST /notifications không đổi
Request — không đổi
Response { data: Notification } / { data: Notification[] } thêm entityType: string | null, entityId: string | null
Lỗi — không đổi

Việc bên nhận cần làm

  • FE: thêm entityType/entityId vào type Notification (frontend/src/modules/identity/api/notifications.api.ts).
  • FE: khi bấm 1 thông báo có entityType, điều hướng tới trang chi tiết tương ứng (request → trang chi tiết đề xuất, ...); null thì giữ hành vi hiện tại (mở /notifications).

Cách kiểm tra

GET /notifications (identity :3001) — mỗi phần tử có thêm 2 field trên. Sau khi REQUEST-021 xong: tạo 1 đề xuất, đợi ~5 giây, người duyệt thấy thông báo với entityType: "request", entityId = id đề xuất.

Thảo luận

[BE] 2026-09-24 @ThaiThanhLuan — raised

Additive, không phá client hiện tại. Mobile n/a: mobile/ chưa có code.

[FE] 2026-09-24 @NinelXram — applied

Đã thêm entityType/entityId vào type Notification; bấm thông báo (chuông và /notifications) điều hướng theo entityType (IDENTITY-FE-006, commit a05f193, PR chưa mở).