mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
normalize HitAndRun::getIsEnabled()
This commit is contained in:
@@ -57,7 +57,8 @@ class HitAndRun extends NexusModel
|
||||
|
||||
public static function getIsEnabled(): bool
|
||||
{
|
||||
return Setting::get('hr.mode') != self::MODE_DISABLED;
|
||||
$result = Setting::get('hr.mode');
|
||||
return $result && in_array($result, [self::MODE_GLOBAL, self::MODE_MANUAL]);
|
||||
}
|
||||
|
||||
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
||||
@@ -13,8 +13,7 @@ class BonusRepository extends BaseRepository
|
||||
{
|
||||
public function consumeToCancelHitAndRun($uid, $hitAndRunId)
|
||||
{
|
||||
$hitAndRunMode = Setting::get('hr.mode');
|
||||
if ($hitAndRunMode == HitAndRun::MODE_DISABLED) {
|
||||
if (!HitAndRun::getIsEnabled()) {
|
||||
throw new \LogicException("H&R not enabled.");
|
||||
}
|
||||
$user = User::query()->findOrFail($uid);
|
||||
@@ -44,6 +43,7 @@ class BonusRepository extends BaseRepository
|
||||
'now' => Carbon::now()->toDateTimeString(),
|
||||
'bonus' => $requireBonus,
|
||||
], $user->locale);
|
||||
$comment = addslashes($comment);
|
||||
do_log("comment: $comment");
|
||||
$hitAndRun->update([
|
||||
'status' => HitAndRun::STATUS_PARDONED,
|
||||
|
||||
Reference in New Issue
Block a user