admin user add link + upload over speed msg

This commit is contained in:
xiaomlove
2022-10-06 18:19:39 +08:00
parent 2737302281
commit fac5ad3cc8
17 changed files with 67 additions and 18 deletions

View File

@@ -464,7 +464,7 @@ class HitAndRunRepository extends BaseRepository
private function getCanPardonStatus(): array
{
return [HitAndRun::STATUS_INSPECTING, HitAndRun::STATUS_UNREACHED];
return HitAndRun::CAN_PARDON_STATUS;
}
public function renderOnUploadPage($value, $searchBoxId): string

View File

@@ -593,7 +593,7 @@ class TrackerRepository extends BaseRepository
$notSeedBoxMaxSpeedMbps = Setting::get('seed_box.not_seed_box_max_speed');
do_log("upSpeedMbps: $upSpeedMbps, notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps");
if ($upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $user, 'no');
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $user, 'no', 'upload_over_speed');
do_log("user: {$user->id} downloading privileges have been disabled! (over speed)", 'error');
throw new TrackerException("Your downloading privileges have been disabled! (over speed)");
}

View File

@@ -326,7 +326,7 @@ class UserRepository extends BaseRepository
}
public function updateDownloadPrivileges($operator, $user, $status)
public function updateDownloadPrivileges($operator, $user, $status, $disableReasonKey = null)
{
if (!in_array($status, ['yes', 'no'])) {
throw new \InvalidArgumentException("Invalid status: $status");
@@ -345,8 +345,12 @@ class UserRepository extends BaseRepository
if ($status == 'no') {
$update = ['downloadpos' => 'no'];
$modComment = date('Y-m-d') . " - Download disable by " . $operatorUsername;
$message['subject'] = nexus_trans('message.download_disable.subject', [], $targetUser->locale);
$message['msg'] = nexus_trans('message.download_disable.body', ['operator' => $operatorUsername], $targetUser->locale);
$msgTransPrefix = "message.download_disable";
if ($disableReasonKey !== null) {
$msgTransPrefix .= "_$disableReasonKey";
}
$message['subject'] = nexus_trans("$msgTransPrefix.subject", [], $targetUser->locale);
$message['msg'] = nexus_trans("$msgTransPrefix.body", ['operator' => $operatorUsername], $targetUser->locale);
} else {
$update = ['downloadpos' => 'yes'];
$modComment = date('Y-m-d') . " - Download enable by " . $operatorUsername;