refactor(suspensions): reorder methods to a logical order, remove makePermanent
This commit is contained in:
parent
980f3a2ee0
commit
b41d3b8d67
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user