diff --git a/src/main/java/app/entities/db/Ban.java b/src/main/java/app/entities/db/Ban.java index 89c1f38..e0cbdd5 100644 --- a/src/main/java/app/entities/db/Ban.java +++ b/src/main/java/app/entities/db/Ban.java @@ -1,6 +1,7 @@ package app.entities.db; import app.entities.other.SteamID; +import app.services.db.PermitionService; import app.utils.CryptedCookie; import app.utils.SteamIDConverter; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -25,6 +26,7 @@ public class Ban { String unbanned_by_id; Timestamp unbanned_timestamp; AdminInfo admin_info; + AdminInfo unbanned_admin_info; public Ban(Object[] obj) { id = (int) obj[0]; @@ -51,7 +53,11 @@ public class Ban { } @JsonIgnore - public SteamID getModeration() { - return SteamIDConverter.getSteamID(banned_by_id); + public void fillAdmins(PermitionService permitionService) { + setAdmin_info(permitionService.getAdminInfo(SteamIDConverter.getSteamID(banned_by_id))); + if (!active) { + if (unbanned_by_id == null || unbanned_by_id.isEmpty() || unbanned_by_id.equals("STEAM_0:0:0")) {} + else setUnbanned_admin_info(permitionService.getAdminInfo(SteamIDConverter.getSteamID(unbanned_by_id))); + } } } diff --git a/src/main/java/app/services/db/BanService.java b/src/main/java/app/services/db/BanService.java index 0d8e028..16fdbdd 100644 --- a/src/main/java/app/services/db/BanService.java +++ b/src/main/java/app/services/db/BanService.java @@ -38,7 +38,7 @@ public class BanService { .getResultList(); return result.stream().map(Ban::new) .peek(ban -> ban.cryptIP(cryptedCookie)) - .peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration()))) + .peek(ban -> ban.fillAdmins(permitionService)) .findFirst() .orElse(null); } @@ -49,7 +49,7 @@ public class BanService { .getResultList(); return result.stream().map(Ban::new) .peek(ban -> ban.cryptIP(cryptedCookie)) - .peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration()))) + .peek(ban -> ban.fillAdmins(permitionService)) .findFirst() .orElse(null); } @@ -60,7 +60,7 @@ public class BanService { .getResultList(); return result.stream().map(Ban::new) .peek(ban -> ban.cryptIP(cryptedCookie)) - .peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration()))) + .peek(ban -> ban.fillAdmins(permitionService)) .toList(); } @@ -70,7 +70,7 @@ public class BanService { .setParameter(2, limit) .getResultStream().map(obj -> new Ban((Object[]) obj)).toList()).stream() .peek(ban -> ban.cryptIP(cryptedCookie)) - .peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration()))) + .peek(ban -> ban.fillAdmins(permitionService)) .toList(); //этот каст конечно пиздец, но он работает }