dev add context for notifcations
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-05-13 13:39:02 +07:00
parent 0546f6acd5
commit 48c14d475d
10 changed files with 154 additions and 21 deletions
@@ -1,5 +1,7 @@
package ru.soune.nocopy.service.complaint;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
@@ -117,8 +119,7 @@ public class ComplaintEntityService {
if (request.getStatus() != null) {
complaint.setStatus(ComplaintStatus.valueOf(request.getStatus()));
notificationService.addNotification(NotificationType.COMPLAINT_STATUS_CHANGED, complaint.getViolation()
.getFileEntity().getUserId(), request.getStatus());
addComplaintNotification(complaint, request);
}
return mapToResponse(complaintRepository.save(complaint));
@@ -146,4 +147,17 @@ public class ComplaintEntityService {
.notModerated(entity.getNot_moderated_file() != null ? entity.getNot_moderated_file() : null)
.build();
}
private void addComplaintNotification(ComplaintEntity complaint, ComplaintRequest request) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode context = mapper.createObjectNode();
context.put("new_status", request.getStatus());
context.put("old_status", complaint.getStatus().name());
context.put("violation", complaint.getViolation().getId());
context.put("file", complaint.getViolation().getFileEntity().getOriginalFileName());
context.put("file_support_id", complaint.getViolation().getFileEntity().getSupportId());
notificationService.addNotification(NotificationType.COMPLAINT_STATUS_CHANGED, complaint.getViolation()
.getFileEntity().getUserId(), context.toString());
}
}