Skip to main content

PHXHighlightActionService

Tài liệu này sử dụng hai khái niệm:

  • Required Action: hành động đang chờ người dùng xử lý.
  • Required Action Highlight: nội dung nổi bật của Required Action.

Các field notification bắt buộc xem tại PHXPushNotificationService.

Ví dụ dùng:

action_code    : FEEDBACK_GENERAL:OPEN_NOTI_FEEDBACK
task_target_id : String(feedback_id)
menu_key : gopY // mobile truyền lên

task_target_id phải là ID nghiệp vụ thật và giống nhau ở bước tạo, kiểm tra trạng thái pending và complete.

Tạo Required Action và Required Action Highlight

Trong payload PHXPushNotificationServiceV2.send(...), bổ sung:

{
action_code: 'FEEDBACK_GENERAL:OPEN_NOTI_FEEDBACK',
mobile_push: {
data: {
payload: {
highlight_title: 'Phản hồi góp ý',
highlight_description: 'Nhà trường đã phản hồi góp ý của bạn.',
},
},
},
create_required_action: {
enabled: true,
data: { task_target_id: String(feedbackId) },
},
}

create_required_action tạo Required Action. Hai field highlight_* tạo nội dung Required Action Highlight và có thể bỏ nếu dùng nội dung notification hoặc cấu hình mặc định.

Kiểm tra Required Action

Mobile truyền menu_key; backend lấy danh sách pending bằng PHXHighlightActionService:

const response = await this.highlightActionService.getItems({
headers,
menuKey,
});

Required Action còn pending khi ID nghiệp vụ khớp reference_id hoặc refId trong response. Không suy ra trạng thái này từ isSeen hay trạng thái nghiệp vụ khác.

Hoàn thành

Sau khi xác thực bản ghi và quyền truy cập, complete bằng đúng user, action_codetask_target_id lúc tạo:

await this.pushNotificationService.completeRequireAction({
hostname,
user_id: parentId,
app: "PARENT",
action_code: "FEEDBACK_GENERAL:OPEN_NOTI_FEEDBACK",
task_target_id: String(feedbackId),
});

Sau khi complete, ID không còn trong danh sách Required Action pending.