refactor(suspensions): reorder methods to a logical order, remove makePermanent

This commit is contained in:
Miguel Nogueira 2022-08-19 02:57:46 +01:00
parent 980f3a2ee0
commit b41d3b8d67
No known key found for this signature in database
GPG Key ID: 3C6A7E29AF26D370

View File

@ -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