IAM - Notification center¶
- Status: Implemented
- Prefix:
NTF - Module: iam
- Feature: notification-center
- Related: IAM index, Sign-in, Activity log, Customer workspace
Purpose¶
A tenant admin keeps the workspace announcement catalog: guides and notices, each a draft or published. The catalog is stored in the tenant database. The header bell shows published rows to every signed-in user, and each user has their own read state.
Users and permissions¶
super_admin and admin may list every row and may add, edit, and delete. tenant_owner and user may list published rows only, including from the header bell. They receive 403 on the management list and on every write. A caller who is not signed in receives 401. The management screen is in the Quản trị doanh nghiệp group, so tenant owners and users do not see its navigation item.
Requirements¶
| ID | Priority | Requirement |
|---|---|---|
| NTF-06 | Must | The management list returns the current tenant's notices, 10 per page, newest first. The request has no tenant id. Columns are title, type, author, created date, and status. A missing session receives 401. A signed-in tenant_owner or user receives 403 on this list. |
| NTF-07 | Must | Refresh reloads the page currently on screen. |
| NTF-08 | Must | Thêm creates a notice. The author is the signed-in admin's display name. The form requires a title, a type (guide or announcement), and a status (draft or published). A blank title is rejected. |
| NTF-09 | Must | Sửa changes the title, type, and status. Xóa removes the row. An unknown id receives 404. A non-admin receives 403. |
| NTF-10 | Must | Nhập Excel creates notices from a CSV file whose columns are Tiêu đề, Loại, and Trạng thái. Loại is Hướng dẫn or Thông báo. Trạng thái is Nháp or Đã đăng. A row with a blank title or an unknown value is skipped. The author of imported rows is the signed-in admin. |
| NTF-11 | Must | A development server starts with 22 fixed sample notices covering both types and both statuses. The first page has 10 rows, the second page has the next 10, and the third page has the last 2. Production starts empty. |
| NTF-12 | Must | The header bell opens a panel directly under the button. A click outside closes it. The panel lists published notices for the signed-in user, newest first, 10 per page. Drafts are not shown. Any signed-in user may open that list. The bell badge is that user's unread count of notices that are still visible, and is hidden when the count is zero. |
| NTF-13 | Must | Notices are stored in the tenant database (iam.announcements). Create, edit, and delete stay after a restart. Development inserts the 22 sample rows only when the table is empty. Production does not insert them. |
| NTF-14 | Must | Read state belongs to one user. Marking one published notice read, or marking all of them read, changes only that user's unread count. A draft or an unknown id receives 404. Marking the same notice again is allowed. |
| NTF-15 | Must | A member added, locked, or removed, and a contract signed, invoice issued, or task assigned, is an integration event. The center turns each new event into one published notice authored by Hệ thống. Delivering the same event id again does not create a second notice. |
| NTF-16 | Must | Publishing a notice emails every active workspace user when SMTP is configured. A draft does not send mail. A mail failure leaves the notice saved. |
| NTF-17 | Must | The header bell hears a live update when a notice is published, and reloads the unread count. |
| NTF-18 | Must | Clear records a timestamp for the signed-in user. Notices published at or before that time disappear from that user's bell, and the badge returns to zero. The catalog is unchanged. Another user's bell is unchanged. A notice published after Clear appears again. |
| NTF-19 | Must | The bell inbox returns one page of 10 published notices, newest first, plus the total and the unread count of every visible notice. Opening the panel loads page 1. Scrolling near the bottom of the list loads the next page and appends it. |
Screens¶
Thông báo (/notifications in the tenant app). One table inside the tenant workspace shell, shown only to super_admin and admin. Newest row first. The customer sidebar does not link to this screen. Published notices are read from the header bell.
Columns: Tiêu đề, Loại, Tác giả, Ngày tạo, Trạng thái, Action.
Loại labels are Hướng dẫn and Thông báo. Trạng thái labels are Nháp and Đã đăng. Ngày tạo is DD/MM/YYYY.
Actions above the table: Làm mới, Thêm, and Nhập Excel. Each row's Action column uses outline icons: black pencil (Edit / Sửa) and red trash (Delete / Xóa). The footer shows the visible range, the total, and "Mỗi trang 10", with Trước and Sau.
Thêm and Sửa open a form with tiêu đề, loại, and trạng thái. Nhập Excel accepts a .csv file.
When the caller may not manage notices, the table states that. When there are no rows, the table states that there is no notice yet.
Header bell. Opens a panel under the button, with no page overlay. A click outside closes it. The panel shows published notices, 10 at a time, newest first: title, type, author, and date. Scrolling near the bottom shows “Loading more notices.”, then appends the next page. An unread row is marked Unread and can be marked read. Mark all as read marks every visible published notice read for the signed-in user. Clear hides every notice published up to that moment for this user only; later notices still appear. Drafts are absent. The badge is the unread count of notices that are still visible. A live stream reloads that count when a notice is published. The badge request uses the first inbox page.
Business rules¶
- Types are
guideandannouncement. Statuses aredraftandpublished. - Sort is
createdAtdescending, theniddescending. - Page numbering starts at 1. Page size is 10 and the client cannot change it.
- The author and created time are set by the server. Edit does not change them.
- Development inserts the 22 sample rows when
iam.announcementsis empty. Production does not. Later writes stay in that table. - A notice is unread for a user until that user marks it read. One user's read state does not change another's.
- Clear stores one timestamp per user (
iam.inbox_clears). The inbox includes a published notice only when itscreatedAtis after that timestamp. The management catalog still lists every notice. - Member, contract, invoice, and task changes are integration events in
iam.outbox. The API and the worker claim pending rows. The same event id creates one notice. - Contract, invoice, and task modules do not publish yet. The center already accepts
contract.signed,invoice.issued, andtask.assigned. - Email uses the workspace SMTP settings. The placeholder host
smtp.example.comsends nothing.
Acceptance criteria¶
- NTF-06: An admin receives 10 rows on the first page, with title, type, author, date, and status. A request without a session receives 401. A signed-in user receives 403 on the management list.
- NTF-07: Refresh requests the same page again.
- NTF-08: Thêm stores a notice whose author is the signed-in admin. A blank title is rejected.
- NTF-09: Sửa changes title, type, and status. Xóa removes the row. An unknown id receives 404. A non-admin receives 403.
- NTF-11: Development exposes 22 samples of both types and both statuses. Production exposes an empty catalog.
- NTF-12: The bell opens a panel of published notices under the button, and its badge is the signed-in user's visible unread count.
- NTF-13: An empty catalog receives the 22 development samples once. Production does not seed them. Rows live in the tenant database.
- NTF-14: Marking a published notice read changes only that user. A draft receives 404. Marking all published notices read clears that user's unread count.
- NTF-10: A file with columns Tiêu đề, Loại, and Trạng thái creates the valid rows and skips a blank title.
- NTF-15: One business event creates one published notice. Delivering it again does not create a second notice.
- NTF-16: A published notice is offered to active users by email. A draft is not.
- NTF-17: Publishing a notice notifies the live bell stream.
- NTF-18: Clear hides current notices for that user, leaves the catalog and other users unchanged, and shows a notice published afterwards.
- NTF-19: The inbox returns 10 notices per page with the full unread count and total. Scrolling the panel loads the next page.
Not yet implemented¶
- Publishers in the contract, invoice, and task modules. The center accepts their events; those modules do not exist yet.
- Mobile push. There is no device registration or push provider.
- Excel
.xlsxfiles. Nhập Excel currently accepts CSV.
Out of scope¶
None.