From 754479eb98760d8fc202949b36f4c0a2a23db97c Mon Sep 17 00:00:00 2001 From: akastijn Date: Fri, 24 Oct 2025 22:01:12 +0200 Subject: [PATCH] Refactor: move `actor` and `actorUuid` UUID retrieval to method to thread with auth --- .../controllers/history/HistoryApiController.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/alttd/altitudeweb/controllers/history/HistoryApiController.java b/backend/src/main/java/com/alttd/altitudeweb/controllers/history/HistoryApiController.java index 7983f80..bd6b5e7 100644 --- a/backend/src/main/java/com/alttd/altitudeweb/controllers/history/HistoryApiController.java +++ b/backend/src/main/java/com/alttd/altitudeweb/controllers/history/HistoryApiController.java @@ -242,6 +242,8 @@ public class HistoryApiController implements HistoryApi { HistoryType historyTypeEnum = HistoryType.getHistoryType(type); CompletableFuture result = new CompletableFuture<>(); + final UUID actor = authenticatedUuid.getAuthenticatedUserUuid(); + Connection.getConnection(Databases.LITE_BANS).runQuery(sqlSession -> { try { IdHistoryMapper idMapper = sqlSession.getMapper(IdHistoryMapper.class); @@ -253,7 +255,6 @@ public class HistoryApiController implements HistoryApi { } int changed = editMapper.setReason(historyTypeEnum, id, reason); HistoryRecord after = idMapper.getRecentHistory(historyTypeEnum, id); - UUID actor = authenticatedUuid.getAuthenticatedUserUuid(); log.info("[Punishment Edit] Actor={} Type={} Id={} Reason: '{}' -> '{}' (rows={})", actor, historyTypeEnum, id, before.getReason(), after != null ? after.getReason() : null, changed); result.complete(after != null ? mapPunishmentHistory(after) : null); @@ -275,6 +276,8 @@ public class HistoryApiController implements HistoryApi { HistoryType historyTypeEnum = HistoryType.getHistoryType(type); CompletableFuture result = new CompletableFuture<>(); + final UUID actor = authenticatedUuid.getAuthenticatedUserUuid(); + Connection.getConnection(Databases.LITE_BANS).runQuery(sqlSession -> { try { IdHistoryMapper idMapper = sqlSession.getMapper(IdHistoryMapper.class); @@ -286,7 +289,6 @@ public class HistoryApiController implements HistoryApi { } int changed = editMapper.setUntil(historyTypeEnum, id, until); HistoryRecord after = idMapper.getRecentHistory(historyTypeEnum, id); - UUID actor = authenticatedUuid.getAuthenticatedUserUuid(); log.info("[Punishment Edit] Actor={} Type={} Id={} Until: '{}' -> '{}' (rows={})", actor, historyTypeEnum, id, before.getUntil(), after != null ? after.getUntil() : null, changed); result.complete(after != null ? mapPunishmentHistory(after) : null); @@ -311,6 +313,8 @@ public class HistoryApiController implements HistoryApi { HistoryType historyTypeEnum = HistoryType.getHistoryType(type); CompletableFuture result = new CompletableFuture<>(); + final UUID actorUuid = authenticatedUuid.getAuthenticatedUserUuid(); + Connection.getConnection(Databases.LITE_BANS).runQuery(sqlSession -> { try { IdHistoryMapper idMapper = sqlSession.getMapper(IdHistoryMapper.class); @@ -320,7 +324,6 @@ public class HistoryApiController implements HistoryApi { result.complete(false); return; } - UUID actorUuid = authenticatedUuid.getAuthenticatedUserUuid(); String actorName = sqlSession.getMapper(RecentNamesMapper.class).getUsername(actorUuid.toString()); int changed = editMapper.remove(historyTypeEnum, id); log.info("[Punishment Remove] Actor={} ({}) Type={} Id={} Before(active={} removedBy={} reason='{}') (rows={})",