From b77efcbce506ebf392baa7b457c1a98093282c56 Mon Sep 17 00:00:00 2001 From: backdev-1 Date: Wed, 13 May 2026 14:27:01 +0700 Subject: [PATCH] dev add context for notifcations --- .../nocopy/dto/notification/NotificationDto.java | 2 +- .../ru/soune/nocopy/handler/NotificationHandler.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/soune/nocopy/dto/notification/NotificationDto.java b/src/main/java/ru/soune/nocopy/dto/notification/NotificationDto.java index 5b9197d..6eb3d91 100644 --- a/src/main/java/ru/soune/nocopy/dto/notification/NotificationDto.java +++ b/src/main/java/ru/soune/nocopy/dto/notification/NotificationDto.java @@ -15,5 +15,5 @@ public class NotificationDto { private NotificationType type; private NotificationStatus status; private LocalDateTime createdAt; - private String context; + private Object context; } diff --git a/src/main/java/ru/soune/nocopy/handler/NotificationHandler.java b/src/main/java/ru/soune/nocopy/handler/NotificationHandler.java index 0736508..6af416b 100644 --- a/src/main/java/ru/soune/nocopy/handler/NotificationHandler.java +++ b/src/main/java/ru/soune/nocopy/handler/NotificationHandler.java @@ -153,13 +153,23 @@ public class NotificationHandler implements RequestHandler { } private NotificationDto toDto(Notification notification) { + Object contextObject = null; + if (notification.getContext() != null) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + contextObject = objectMapper.readValue(notification.getContext(), Object.class); + } catch (Exception e) { + contextObject = notification.getContext(); + } + } + return NotificationDto.builder() .id(notification.getId()) .message(notification.getMessage()) .type(notification.getNotificationType()) .status(notification.getStatus()) .createdAt(notification.getCreatedAt()) - .context(notification.getContext()) + .context(contextObject) .build(); } }