This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user