RED-5949: Wrong notificationType for specific endpoint

* Do not send notification if assigneeId is null
This commit is contained in:
maverickstuder 2024-01-15 12:20:54 +01:00
parent f148c6fa6d
commit 9ac8fcbf38

View File

@ -350,14 +350,16 @@ public class StatusController implements StatusResource {
private void generatePossibleUnassignedFromFileNotification(String dossierId, String fileId, FileModel oldFileStatus, String newAssigneeId) {
if (oldFileStatus.getAssignee() != null && !oldFileStatus.getAssignee().equals(newAssigneeId) && !KeycloakSecurity.getUserId().equals(oldFileStatus.getAssignee())) {
notificationPersistenceService.insertNotification(AddNotificationRequest.builder()
.userId(oldFileStatus.getAssignee())
.issuerId(KeycloakSecurity.getUserId())
.notificationType(NotificationType.UNASSIGNED_FROM_FILE.name())
.target(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, FILE_NAME, oldFileStatus.getFilename()))
.build());
if (oldFileStatus.getAssignee() == null || newAssigneeId == null || oldFileStatus.getAssignee().equals(newAssigneeId) || KeycloakSecurity.getUserId().equals(oldFileStatus.getAssignee())) {
return;
}
notificationPersistenceService.insertNotification(AddNotificationRequest.builder()
.userId(oldFileStatus.getAssignee())
.issuerId(KeycloakSecurity.getUserId())
.notificationType(NotificationType.UNASSIGNED_FROM_FILE.name())
.target(Map.of(DOSSIER_ID, dossierId, FILE_ID, fileId, FILE_NAME, oldFileStatus.getFilename()))
.build());
}