From 88180f9009fd68b08249654e87eb674256f895cb Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Fri, 5 Jun 2026 17:58:37 +0300 Subject: [PATCH] minor refactoring --- .../server/controller/AlarmCommentController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/AlarmCommentController.java b/application/src/main/java/org/thingsboard/server/controller/AlarmCommentController.java index 0bcce4be83..aae7670d20 100644 --- a/application/src/main/java/org/thingsboard/server/controller/AlarmCommentController.java +++ b/application/src/main/java/org/thingsboard/server/controller/AlarmCommentController.java @@ -82,7 +82,7 @@ public class AlarmCommentController extends BaseController { SecurityUser currentUser = getCurrentUser(); if (alarmComment.getId() != null) { AlarmComment existingAlarmComment = checkAlarmCommentId(alarmComment.getId(), alarmId); - checkUserCommentOwnership(existingAlarmComment, Operation.WRITE, currentUser); + checkUserCommentOwnership(existingAlarmComment, "edit", currentUser); } alarmComment.setAlarmId(alarmId); alarmComment.setType(AlarmCommentType.OTHER); @@ -101,7 +101,7 @@ public class AlarmCommentController extends BaseController { AlarmCommentId alarmCommentId = new AlarmCommentId(toUUID(strCommentId)); AlarmComment alarmComment = checkAlarmCommentId(alarmCommentId, alarmId); SecurityUser currentUser = getCurrentUser(); - checkUserCommentOwnership(alarmComment, Operation.DELETE, currentUser); + checkUserCommentOwnership(alarmComment, "delete", currentUser); tbAlarmCommentService.deleteAlarmComment(alarm, alarmComment, currentUser); } @@ -129,12 +129,12 @@ public class AlarmCommentController extends BaseController { return checkNotNull(alarmCommentService.findAlarmComments(alarm.getTenantId(), alarmId, pageLink)); } - private void checkUserCommentOwnership(AlarmComment alarmComment, Operation operation, SecurityUser securityUser) throws ThingsboardException { + private void checkUserCommentOwnership(AlarmComment alarmComment, String action, SecurityUser securityUser) throws ThingsboardException { if (securityUser.isTenantAdmin()) { return; } if (alarmComment.getUserId() != null && !alarmComment.getUserId().equals(securityUser.getId())) { - throw new ThingsboardException("User is not allowed to " + (operation == Operation.DELETE ? "delete" : "edit") + " other user's comment", + throw new ThingsboardException("User is not allowed to " + action + " other user's comment", ThingsboardErrorCode.PERMISSION_DENIED); } }