refactor(suspensions): change method signature to support null argument for suspension duration
This commit is contained in:
parent
697547f42d
commit
980f3a2ee0
@ -18,12 +18,12 @@ class AccountSuspensionService
|
|||||||
* Suspends a user account, with given $reason.
|
* Suspends a user account, with given $reason.
|
||||||
* Permanent if no duration given.
|
* Permanent if no duration given.
|
||||||
*
|
*
|
||||||
* @param string $reason Suspension reason.
|
|
||||||
* @param int $duration Duration in days
|
|
||||||
* @param User $target Who to suspend.
|
* @param User $target Who to suspend.
|
||||||
|
* @param string $reason Suspension reason.
|
||||||
|
* @param int|null $duration Duration in days
|
||||||
* @return Ban The ban itself
|
* @return Ban The ban itself
|
||||||
*/
|
*/
|
||||||
public function suspend(User $target, string $reason, int $duration = 0): Ban {
|
public function suspend(User $target, string $reason, int $duration = null): Ban {
|
||||||
|
|
||||||
Log::alert("An user account has just been suspended.", [
|
Log::alert("An user account has just been suspended.", [
|
||||||
'taget_email' => $target->email,
|
'taget_email' => $target->email,
|
||||||
@ -125,7 +125,7 @@ class AccountSuspensionService
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSuspensionDuration(User $user): string|null {
|
public function getSuspensionDuration(User $user): string|null {
|
||||||
if ($this->isSuspended($user)) {
|
if ($this->isSuspended($user) && !is_null($user->bans->bannedUntil)) {
|
||||||
return $user->bans->bannedUntil->diffForHumans();
|
return $user->bans->bannedUntil->diffForHumans();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user