Set ban through AccountService

This commit is contained in:
P0nk
2024-09-29 19:26:15 +02:00
parent f142e21bbb
commit 99006c2dda
5 changed files with 87 additions and 50 deletions

View File

@@ -14,6 +14,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.util.Optional;
@@ -66,6 +67,10 @@ public class AccountService {
return accountRepository.findById(accountId);
}
public Optional<Account> getAccountIdByChrName(String chrName) {
return accountRepository.findIdByChrNameIgnoreCase(chrName);
}
public boolean acceptTos(int accountId) {
acceptTosMysql(accountId);
acceptTosPostgres(accountId);
@@ -274,4 +279,13 @@ public class AccountService {
}
}
public void permaBan(int accountId, byte banReason, String description) {
accountRepository.setBanned(accountId, null, banReason, description);
}
public void tempBan(int accountId, Duration duration, byte banReason, String description) {
Instant bannedUntil = Instant.now().plus(duration);
accountRepository.setBanned(accountId, bannedUntil, banReason, description);
}
}