This commit is contained in:
xiaomlove
2025-09-14 00:47:09 +07:00
parent 4c46f376ba
commit c74c88f5a5
10 changed files with 65 additions and 22 deletions

View File

@@ -24,7 +24,7 @@ class TorrentUpdated
* *
* @return void * @return void
*/ */
public function __construct(Model $model, Model $modelOld) public function __construct(Model $model, ?Model $modelOld = null)
{ {
$this->model = $model; $this->model = $model;
$this->modelOld = $modelOld; $this->modelOld = $modelOld;

View File

@@ -363,10 +363,9 @@ class TorrentResource extends Resource
return $result; return $result;
}) })
->reactive() ->reactive()
->afterStateUpdated(fn (callable $set) => $set('section_id', null))
->required() ->required()
, ,
Forms\Components\Select::make('category') Forms\Components\Select::make('category_id')
->label(__('searchbox.category_label')) ->label(__('searchbox.category_label'))
->options(function (callable $get) { ->options(function (callable $get) {
$sectionId = $get('section_id'); $sectionId = $get('section_id');
@@ -375,19 +374,17 @@ class TorrentResource extends Resource
} }
return Category::query()->where('mode', $sectionId)->pluck('name', 'id'); return Category::query()->where('mode', $sectionId)->pluck('name', 'id');
}) })
->reactive()
->required() ->required()
, ,
]) ])
->action(function (Collection $records, array $data) { ->action(function (Collection $records, array $data) {
// $torrentRep = new TorrentRepository(); $torrentRep = new TorrentRepository();
// try { try {
// $data['torrent_id'] = $record->id; $torrentRep->changeCategory($records, $data['section_id'], $data['category_id']);
// $torrentRep->approval(Auth::user(), $data); } catch (\Exception $exception) {
// } catch (\Exception $exception) { do_log($exception->getMessage(), 'error');
// do_log($exception->getMessage(), 'error'); }
// }
}); });
} }

View File

@@ -333,7 +333,7 @@ class SeedBoxRepository extends BaseRepository
$asnObj = $reader->asn($ip); $asnObj = $reader->asn($ip);
return $asnObj->autonomousSystemNumber ?? 0; return $asnObj->autonomousSystemNumber ?? 0;
} catch (\Exception $e) { } catch (\Exception $e) {
do_log("ip: $ip, error: " . $e->getMessage(), 'error'); do_log("ip: $ip, error: " . $e->getMessage());
return 0; return 0;
} }
}); });

View File

@@ -4,6 +4,7 @@ namespace App\Repositories;
use App\Auth\Permission; use App\Auth\Permission;
use App\Enums\ModelEventEnum; use App\Enums\ModelEventEnum;
use App\Events\TorrentUpdated;
use App\Exceptions\InsufficientPermissionException; use App\Exceptions\InsufficientPermissionException;
use App\Exceptions\NexusException; use App\Exceptions\NexusException;
use App\Http\Resources\TorrentResource; use App\Http\Resources\TorrentResource;
@@ -18,6 +19,7 @@ use App\Models\Peer;
use App\Models\Processing; use App\Models\Processing;
use App\Models\SearchBox; use App\Models\SearchBox;
use App\Models\Setting; use App\Models\Setting;
use App\Models\SiteLog;
use App\Models\Snatch; use App\Models\Snatch;
use App\Models\Source; use App\Models\Source;
use App\Models\StaffMessage; use App\Models\StaffMessage;
@@ -36,6 +38,7 @@ use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@@ -1095,4 +1098,33 @@ HTML;
} }
} }
public function changeCategory(Collection $torrents, int $sectionId, int $categoryId): void
{
assert_has_permission(Permission::canManageTorrent());
$searchBox = SearchBox::query()->findOrFail($sectionId);
$category = $searchBox->categories()->findOrFail($categoryId);
$torrentIdArr = $torrents->pluck('id')->toArray();
if (empty($torrentIdArr)) {
do_log("torrents is empty", 'warn');
return;
}
$operatorId = get_user_id();
$siteLogArr = [];
foreach ($torrents as $torrent) {
$siteLogArr[] = [
'added' => now(),
'txt' => sprintf("torrent: %s category was set to: %s(%s)", $torrent->id, $category->name, $category->id),
'uid' => $operatorId,
];
}
NexusDB::transaction(function () use ($torrentIdArr, $categoryId, $siteLogArr) {
SiteLog::query()->insert($siteLogArr);
Torrent::query()->whereIn('id', $torrentIdArr)->update(['category' => $categoryId]);
});
foreach ($torrents as $torrent) {
fire_event(ModelEventEnum::TORRENT_UPDATED, $torrent);
}
do_log("success change torrent category to $categoryId, torrent count:" . $torrents->count());
}
} }

View File

@@ -183,7 +183,7 @@ return [
'defaults' => [ 'defaults' => [
'supervisor-1' => [ 'supervisor-1' => [
'connection' => 'redis', 'connection' => 'redis',
'queue' => ['default', 'nexus_queue'], 'queue' => ['nexus_queue'],
'balance' => 'auto', 'balance' => 'auto',
'autoScalingStrategy' => 'time', 'autoScalingStrategy' => 'time',
'maxProcesses' => 1, 'maxProcesses' => 1,

View File

@@ -2331,7 +2331,7 @@ function get_css_row() {
} }
$Cache->cache_value('stylesheet_content', $rows, 95400); $Cache->cache_value('stylesheet_content', $rows, 95400);
} }
return $rows[$cssid]; return $rows[$cssid] ?? $rows[$defcss];
} }
function get_css_uri($file = "") function get_css_uri($file = "")
{ {
@@ -6300,13 +6300,11 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
$baseBonusFactor = $donortimes_bonus; $baseBonusFactor = $donortimes_bonus;
} }
$baseBonus = $bonusResult['seed_bonus'] * $baseBonusFactor; $baseBonus = $bonusResult['seed_bonus'] * $baseBonusFactor;
$totalBonus = number_format( $totalBonus = $baseBonus
$baseBonus
+ $haremAddition * $haremFactor + $haremAddition * $haremFactor
+ $bonusResult['official_bonus'] * $officialAdditionalFactor + $bonusResult['official_bonus'] * $officialAdditionalFactor
+ $bonusResult['medal_bonus'] * $bonusResult['medal_additional_factor'] + $bonusResult['medal_bonus'] * $bonusResult['medal_additional_factor']
, 3 ;
);
$rowSpan = 1; $rowSpan = 1;
$hasHaremAddition = $hasOfficialAddition = $hasMedalAddition = false; $hasHaremAddition = $hasOfficialAddition = $hasMedalAddition = false;

View File

@@ -1280,6 +1280,13 @@ function user_can($permission, $fail = false, $uid = 0): bool
throw new \App\Exceptions\InsufficientPermissionException(); throw new \App\Exceptions\InsufficientPermissionException();
} }
function assert_has_permission(bool $permissionCheckResult): void
{
if (!$permissionCheckResult) {
throw new \App\Exceptions\InsufficientPermissionException();
}
}
function is_donor(array $userInfo): bool function is_donor(array $userInfo): bool

View File

@@ -13,7 +13,7 @@ if (isset($_GET['del']))
} }
} }
$where=$_GET["type"] ?? ''; $where=$_GET["type"] ?? '';
$refresh = ($CURUSER['sbrefresh'] ? $CURUSER['sbrefresh'] : 120) $refresh = ($CURUSER['sbrefresh'] ?? 120)
?> ?>
<html><head> <html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

View File

@@ -10,10 +10,18 @@ if (($CURUSER['id'] != $id && !user_can('viewinvite')) || !is_valid_id($id))
$email = unesc(htmlspecialchars(trim($_POST["email"]))); $email = unesc(htmlspecialchars(trim($_POST["email"])));
if(!empty($_POST['conusr'])) { if(!empty($_POST['conusr'])) {
// sql_query("UPDATE users SET status = 'confirmed', editsecret = '' WHERE id IN (" . implode(", ", $_POST['conusr']) . ") AND status='pending'"); // sql_query("UPDATE users SET status = 'confirmed', editsecret = '' WHERE id IN (" . implode(", ", $_POST['conusr']) . ") AND status='pending'");
\App\Models\User::query()->whereIn('id', $_POST['conusr']) $userList = \App\Models\User::query()->whereIn('id', $_POST['conusr'])
->where('status', 'pending') ->where('status', 'pending')
->update(['status' => 'confirmed', 'editsecret' => '']) ->get(\App\Models\User::$commonFields)
; ;
if ($userList->isNotEmpty()) {
$uidArr = [];
foreach ($userList as $user) {
$uidArr[] = $user->id;
fire_event(\App\Enums\ModelEventEnum::USER_UPDATED, $user);
}
\App\Models\User::query()->whereIn('id', $uidArr)->update(['status' => 'confirmed', 'editsecret' => '']);
}
} else { } else {
stderr($lang_takeconfirm['std_sorry'],$lang_takeconfirm['std_no_buddy_to_confirm']. stderr($lang_takeconfirm['std_sorry'],$lang_takeconfirm['std_no_buddy_to_confirm'].
"<a class=altlink href=invite.php?id={$CURUSER['id']}>".$lang_takeconfirm['std_here_to_go_back'],false); "<a class=altlink href=invite.php?id={$CURUSER['id']}>".$lang_takeconfirm['std_here_to_go_back'],false);

View File

@@ -4,7 +4,8 @@ $passkey = $_GET['passkey'] ?? $CURUSER['passkey'] ?? '';
if (!$passkey) { if (!$passkey) {
die("require passkey"); die("require passkey");
} }
$cacheKey = "nexus_rss:$passkey:" . md5(http_build_query($_GET)); unset($_GET['passkey']);
$cacheKey = "nexus_rss:" . md5(http_build_query($_GET));
$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey); $cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey);
if ($cacheData && nexus_env('APP_ENV') != 'local') { if ($cacheData && nexus_env('APP_ENV') != 'local') {
do_log("rss get from cache"); do_log("rss get from cache");