-
Notifications
You must be signed in to change notification settings - Fork 11
feat(notifications): mark-read flows (PR 2/7) #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,8 @@ import { BaseService } from '../base'; | |||||||||
| import type { | ||||||||||
| NotificationGetAllOptions, | ||||||||||
| NotificationGetResponse, | ||||||||||
| NotificationMarkAllReadResponse, | ||||||||||
| NotificationUpdateReadResponse, | ||||||||||
| } from '../../models/notification/notifications.types'; | ||||||||||
| import type { | ||||||||||
| NotificationServiceModel, | ||||||||||
|
|
@@ -34,9 +36,8 @@ import { PaginationType } from '../../utils/pagination/internal-types'; | |||||||||
| /** | ||||||||||
| * Service for interacting with the UiPath Notification inbox. | ||||||||||
| * | ||||||||||
| * Provides list operations against the current user's notifications (the | ||||||||||
| * `/odata/v1/NotificationEntry` API). Further inbox operations (mark-read, | ||||||||||
| * delete) land in follow-up PRs. | ||||||||||
| * Provides inbox operations against the current user's notifications (the | ||||||||||
| * `/odata/v1/NotificationEntry` API). | ||||||||||
| * | ||||||||||
|
Comment on lines
+40
to
41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class description was correctly trimmed to remove the stale "mark-read … land in follow-up PRs" sentence, but the first line is still incomplete now that this PR ships the mark-read methods.
Suggested change
Using the broader "inbox operations" keeps the description accurate through future PRs (delete, etc.) without needing another touch-up. |
||||||||||
| * Every public method takes the acting tenant GUID as the first argument — the | ||||||||||
| * notification API identifies the tenant via the `X-UIPATH-Internal-TenantId` | ||||||||||
|
|
@@ -125,4 +126,76 @@ export class NotificationService extends BaseService implements NotificationServ | |||||||||
| : NonPaginatedResponse<NotificationGetResponse> | ||||||||||
| >; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Marks the given notifications as read. | ||||||||||
| * | ||||||||||
| * @param tenantId - Tenant GUID | ||||||||||
| * @param notificationIds - GUIDs of notifications to mark read | ||||||||||
| * @returns Operation result echoing the affected IDs and new read state | ||||||||||
| * {@link NotificationUpdateReadResponse} | ||||||||||
| * | ||||||||||
| * @example | ||||||||||
| * ```typescript | ||||||||||
| * await notifications.markAsRead('<tenantId>', ['<notificationId-1>', '<notificationId-2>']); | ||||||||||
| * ``` | ||||||||||
| * @internal | ||||||||||
| */ | ||||||||||
| @track('Notifications.MarkAsRead') | ||||||||||
| async markAsRead(tenantId: string, notificationIds: string[]): Promise<NotificationUpdateReadResponse> { | ||||||||||
| return this.updateRead(tenantId, notificationIds, true); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Marks the given notifications as unread. | ||||||||||
| * | ||||||||||
| * @param tenantId - Tenant GUID | ||||||||||
| * @param notificationIds - GUIDs of notifications to mark unread | ||||||||||
| * @returns Operation result echoing the affected IDs and new read state | ||||||||||
| * {@link NotificationUpdateReadResponse} | ||||||||||
| * | ||||||||||
| * @example | ||||||||||
| * ```typescript | ||||||||||
| * await notifications.markAsUnread('<tenantId>', ['<notificationId>']); | ||||||||||
| * ``` | ||||||||||
| * @internal | ||||||||||
| */ | ||||||||||
| @track('Notifications.MarkAsUnread') | ||||||||||
| async markAsUnread(tenantId: string, notificationIds: string[]): Promise<NotificationUpdateReadResponse> { | ||||||||||
| return this.updateRead(tenantId, notificationIds, false); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Marks all notifications in the current user's inbox as read. | ||||||||||
| * | ||||||||||
| * @param tenantId - Tenant GUID | ||||||||||
| * @returns Operation result confirming the bulk update | ||||||||||
| * {@link NotificationMarkAllReadResponse} | ||||||||||
| * | ||||||||||
| * @example | ||||||||||
| * ```typescript | ||||||||||
| * await notifications.markAllAsRead('<tenantId>'); | ||||||||||
| * ``` | ||||||||||
| * @internal | ||||||||||
| */ | ||||||||||
| @track('Notifications.MarkAllAsRead') | ||||||||||
| async markAllAsRead(tenantId: string): Promise<NotificationMarkAllReadResponse> { | ||||||||||
| await this.post(NOTIFICATION_ENDPOINTS.UPDATE_READ, { | ||||||||||
| notifications: [], | ||||||||||
| forceAllRead: true, | ||||||||||
| }, { headers: createHeaders({ [TENANT_ID]: tenantId }) }); | ||||||||||
| return { success: true, data: { all: true, read: true } }; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| private async updateRead( | ||||||||||
| tenantId: string, | ||||||||||
| notificationIds: string[], | ||||||||||
| read: boolean | ||||||||||
| ): Promise<NotificationUpdateReadResponse> { | ||||||||||
| await this.post(NOTIFICATION_ENDPOINTS.UPDATE_READ, { | ||||||||||
| notifications: notificationIds.map((notificationId) => ({ notificationId, read })), | ||||||||||
| forceAllRead: false, | ||||||||||
| }, { headers: createHeaders({ [TENANT_ID]: tenantId }) }); | ||||||||||
| return { success: true, data: { notificationIds, read } }; | ||||||||||
| } | ||||||||||
| } | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.