From b41d3b8d6799df279b2f430109ff75b68bd639a9 Mon Sep 17 00:00:00 2001 From: miguel456 Date: Fri, 19 Aug 2022 02:57:46 +0100 Subject: [PATCH] refactor(suspensions): reorder methods to a logical order, remove makePermanent --- app/Services/AccountSuspensionService.php | 48 +++++++---------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/app/Services/AccountSuspensionService.php b/app/Services/AccountSuspensionService.php index 6b8e66a..4a9236a 100755 --- a/app/Services/AccountSuspensionService.php +++ b/app/Services/AccountSuspensionService.php @@ -58,6 +58,16 @@ class AccountSuspensionService $user->bans->delete(); } + /** + * Checks whether a user is suspended + * + * @param User $user The user to check + * @return bool Whether the mentioned user is suspended + */ + public function isSuspended(User $user): bool { + return !is_null($user->bans); + } + @@ -101,19 +111,16 @@ class AccountSuspensionService return $user->save(); } - - /** - * Checks whether a user is suspended + * Checks whether an account is locked * * @param User $user The user to check - * @return bool Whether the mentioned user is suspended + * @return bool Whether the mentioned account is locked */ - public function isSuspended(User $user): bool { - return !is_null($user->bans); + public function isLocked(User $user): bool { + return $user->administratively_locked == 1; } - /** * Retrieves the reason for the user's suspension. * @@ -131,33 +138,6 @@ class AccountSuspensionService return null; } - /** - * Checks whether an account is locked - * - * @param User $user The user to check - * @return bool Whether the mentioned account is locked - */ - public function isLocked(User $user): bool { - return $user->administratively_locked == 1; - } - - /** - * Takes a suspension directly and makes it permanent. - * - * @param Ban $ban The suspension to make permanent - */ - public function makePermanent(Ban $ban): void { - - Log::alert('A suspension has just been made permanent.', [ - 'target_email' => $ban->user->email - ]); - - $ban->bannedUntil = null; - $ban->isPermanent = true; - - $ban->save(); - - } /** * Purges old, expired suspensions from the database