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(); } }