mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-01 07:52:00 -05:00
refactor: use moderation status enum and cast
For consistency and less magic numbers hard coded everywhere.
This commit is contained in:
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\DTO;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\PlaylistTorrent;
|
||||
use App\Models\User;
|
||||
use App\Models\Wish;
|
||||
@@ -422,7 +423,7 @@ readonly class TorrentSearchFiltersDTO
|
||||
|
||||
$filters = [
|
||||
'deleted_at IS NULL',
|
||||
'status = 1',
|
||||
'status = '.ModerationStatus::APPROVED->value,
|
||||
];
|
||||
|
||||
if ($this->uploader !== '') {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ModerationStatus: int
|
||||
{
|
||||
case PENDING = 0;
|
||||
case APPROVED = 1;
|
||||
case REJECTED = 2;
|
||||
case POSTPONED = 3;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ use App\Achievements\UserMade800Uploads;
|
||||
use App\Achievements\UserMade900Uploads;
|
||||
use App\Achievements\UserMadeUpload;
|
||||
use App\Bots\IRCAnnounceBot;
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\AutomaticTorrentFreeleech;
|
||||
use App\Models\Movie;
|
||||
use App\Models\Scopes\ApprovedScope;
|
||||
@@ -49,7 +50,7 @@ class TorrentHelper
|
||||
$torrent = Torrent::with('user')->withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$torrent->created_at = Carbon::now();
|
||||
$torrent->bumped_at = Carbon::now();
|
||||
$torrent->status = Torrent::APPROVED;
|
||||
$torrent->status = ModerationStatus::APPROVED;
|
||||
$torrent->moderated_at = now();
|
||||
$torrent->moderated_by = (int) auth()->id();
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Meilisearch\Client;
|
||||
@@ -30,7 +31,7 @@ class QuickSearchController extends Controller
|
||||
|
||||
$filters = [
|
||||
'deleted_at IS NULL',
|
||||
'status = 1',
|
||||
'status = '.ModerationStatus::APPROVED->value,
|
||||
[
|
||||
'category.movie_meta = true',
|
||||
'category.tv_meta = true',
|
||||
|
||||
@@ -21,6 +21,7 @@ use App\DTO\AnnounceGroupDTO;
|
||||
use App\DTO\AnnounceQueryDTO;
|
||||
use App\DTO\AnnounceTorrentDTO;
|
||||
use App\DTO\AnnounceUserDTO;
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Exceptions\TrackerException;
|
||||
use App\Jobs\ProcessAnnounce;
|
||||
use App\Models\BlacklistClient;
|
||||
@@ -42,11 +43,6 @@ use Illuminate\Support\Facades\Redis;
|
||||
|
||||
final class AnnounceController extends Controller
|
||||
{
|
||||
// Torrent Moderation Codes
|
||||
protected const int PENDING = 0;
|
||||
protected const int REJECTED = 2;
|
||||
protected const int POSTPONED = 3;
|
||||
|
||||
// Announce Intervals
|
||||
private const int MIN = 1_800;
|
||||
private const int MAX = 3_600;
|
||||
@@ -412,17 +408,17 @@ final class AnnounceController extends Controller
|
||||
}
|
||||
|
||||
// If Torrent Is Pending Moderation Return Error to Client
|
||||
if ($torrent->status === self::PENDING) {
|
||||
if ($torrent->status === ModerationStatus::PENDING) {
|
||||
throw new TrackerException(151, [':status' => 'PENDING In Moderation']);
|
||||
}
|
||||
|
||||
// If Torrent Is Rejected Return Error to Client
|
||||
if ($torrent->status === self::REJECTED) {
|
||||
if ($torrent->status === ModerationStatus::REJECTED) {
|
||||
throw new TrackerException(151, [':status' => 'REJECTED In Moderation']);
|
||||
}
|
||||
|
||||
// If Torrent Is Postponed Return Error to Client
|
||||
if ($torrent->status === self::POSTPONED) {
|
||||
if ($torrent->status === ModerationStatus::POSTPONED) {
|
||||
throw new TrackerException(151, [':status' => 'POSTPONED In Moderation']);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Http\Requests\StoreDonationRequest;
|
||||
use App\Models\Donation;
|
||||
use App\Models\DonationGateway;
|
||||
@@ -40,7 +41,7 @@ class DonationController extends Controller
|
||||
public function store(StoreDonationRequest $request)
|
||||
{
|
||||
Donation::create([
|
||||
'status' => Donation::PENDING,
|
||||
'status' => ModerationStatus::PENDING,
|
||||
'package_id' => $request->package_id,
|
||||
'user_id' => auth()->user()->id,
|
||||
'transaction' => $request->transaction,
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Staff\ApproveApplicationRequest;
|
||||
use App\Http\Requests\Staff\RejectApplicationRequest;
|
||||
@@ -60,7 +61,7 @@ class ApplicationController extends Controller
|
||||
{
|
||||
$application = Application::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
|
||||
$application->status = Application::APPROVED;
|
||||
$application->status = ModerationStatus::APPROVED;
|
||||
$application->moderated_at = now();
|
||||
$application->moderated_by = $request->user()->id;
|
||||
$application->save();
|
||||
@@ -86,7 +87,7 @@ class ApplicationController extends Controller
|
||||
{
|
||||
$application = Application::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$application->update([
|
||||
'status' => Application::REJECTED,
|
||||
'status' => ModerationStatus::REJECTED,
|
||||
'moderated_at' => now(),
|
||||
'moderated_by' => $request->user()->id,
|
||||
]);
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Models\Conversation;
|
||||
use App\Services\Unit3dAnnounce;
|
||||
@@ -40,14 +41,14 @@ class DonationController extends Controller
|
||||
|
||||
$dailyDonations = Donation::selectRaw('DATE(donations.created_at) as date, SUM(donation_packages.cost) as total')
|
||||
->join('donation_packages', 'donations.package_id', '=', 'donation_packages.id')
|
||||
->where('donations.status', '=', Donation::APPROVED)
|
||||
->where('donations.status', '=', ModerationStatus::APPROVED)
|
||||
->groupBy('date')
|
||||
->orderBy('date')
|
||||
->get();
|
||||
|
||||
$monthlyDonations = Donation::selectRaw('EXTRACT(YEAR FROM donations.created_at) as year, EXTRACT(MONTH FROM donations.created_at) as month, SUM(donation_packages.cost) as total')
|
||||
->join('donation_packages', 'donations.package_id', '=', 'donation_packages.id')
|
||||
->where('donations.status', '=', Donation::APPROVED)
|
||||
->where('donations.status', '=', ModerationStatus::APPROVED)
|
||||
->groupBy('year', 'month')
|
||||
->orderBy('year')
|
||||
->orderBy('month')
|
||||
@@ -70,7 +71,7 @@ class DonationController extends Controller
|
||||
$now = Carbon::now();
|
||||
|
||||
$donation = Donation::with(['user', 'package'])->findOrFail($id);
|
||||
$donation->status = Donation::APPROVED;
|
||||
$donation->status = ModerationStatus::APPROVED;
|
||||
$donation->starts_at = $now;
|
||||
|
||||
if ($donation->package->donor_value > 0) {
|
||||
@@ -114,7 +115,7 @@ class DonationController extends Controller
|
||||
abort_unless($request->user()->group->is_owner, 403);
|
||||
|
||||
$donation = Donation::findOrFail($id);
|
||||
$donation->status = Donation::REJECTED;
|
||||
$donation->status = ModerationStatus::REJECTED;
|
||||
|
||||
$conversation = Conversation::create(['subject' => 'Your donation from '.$donation->created_at.', has been rejected by '.$request->user()->username]);
|
||||
$conversation->users()->sync([$request->user()->id => ['read' => true], $donation->user_id]);
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\SystemInformation;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Group;
|
||||
@@ -72,7 +73,7 @@ class HomeController extends Controller
|
||||
->selectRaw('SUM(seeder = TRUE AND active = TRUE) AS seeders')
|
||||
->first()),
|
||||
'unsolvedReportsCount' => DB::table('reports')->whereNull('snoozed_until')->where('solved', '=', false)->count(),
|
||||
'pendingApplicationsCount' => DB::table('applications')->where('status', '=', 0)->count(),
|
||||
'pendingApplicationsCount' => DB::table('applications')->where('status', '=', ModerationStatus::PENDING)->count(),
|
||||
'certificate' => $certificate,
|
||||
'uptime' => $systemInformation->uptime(),
|
||||
'ram' => $systemInformation->memory(),
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\TorrentHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Staff\UpdateModerationRequest;
|
||||
@@ -49,15 +50,15 @@ class ModerationController extends Controller
|
||||
'current' => now(),
|
||||
'pending' => Torrent::withoutGlobalScope(ApprovedScope::class)
|
||||
->with(['user.group', 'category', 'type', 'resolution'])
|
||||
->where('status', '=', Torrent::PENDING)
|
||||
->where('status', '=', ModerationStatus::PENDING)
|
||||
->get(),
|
||||
'postponed' => Torrent::withoutGlobalScope(ApprovedScope::class)
|
||||
->with(['user.group', 'moderated.group', 'category', 'type', 'resolution'])
|
||||
->where('status', '=', Torrent::POSTPONED)
|
||||
->where('status', '=', ModerationStatus::POSTPONED)
|
||||
->get(),
|
||||
'rejected' => Torrent::withoutGlobalScope(ApprovedScope::class)
|
||||
->with(['user.group', 'moderated.group', 'category', 'type', 'resolution'])
|
||||
->where('status', '=', Torrent::REJECTED)
|
||||
->where('status', '=', ModerationStatus::REJECTED)
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
@@ -71,30 +72,29 @@ class ModerationController extends Controller
|
||||
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->with('user')->findOrFail($id);
|
||||
|
||||
if ($request->integer('old_status') !== $torrent->status) {
|
||||
if (ModerationStatus::from($request->integer('old_status')) !== $torrent->status) {
|
||||
return to_route('torrents.show', ['id' => $id])
|
||||
->withInput()
|
||||
->withErrors('Torrent has already been moderated since this page was loaded.');
|
||||
}
|
||||
|
||||
if ($request->integer('status') === $torrent->status) {
|
||||
if (ModerationStatus::from($request->integer('status')) === $torrent->status) {
|
||||
return to_route('torrents.show', ['id' => $id])
|
||||
->withInput()
|
||||
->withErrors(
|
||||
match ($torrent->status) {
|
||||
Torrent::PENDING => 'Torrent already pending.',
|
||||
Torrent::APPROVED => 'Torrent already approved.',
|
||||
Torrent::REJECTED => 'Torrent already rejected.',
|
||||
Torrent::POSTPONED => 'Torrent already postponed.',
|
||||
default => 'Invalid moderation status.'
|
||||
ModerationStatus::PENDING => 'Torrent already pending.',
|
||||
ModerationStatus::APPROVED => 'Torrent already approved.',
|
||||
ModerationStatus::REJECTED => 'Torrent already rejected.',
|
||||
ModerationStatus::POSTPONED => 'Torrent already postponed.',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$staff = auth()->user();
|
||||
|
||||
switch ($request->status) {
|
||||
case Torrent::APPROVED:
|
||||
switch (ModerationStatus::from($request->integer('status'))) {
|
||||
case ModerationStatus::APPROVED:
|
||||
// Announce To Shoutbox
|
||||
if (!$torrent->anon) {
|
||||
$this->chatRepository->systemMessage(
|
||||
@@ -111,9 +111,9 @@ class ModerationController extends Controller
|
||||
return to_route('staff.moderation.index')
|
||||
->with('success', 'Torrent Approved');
|
||||
|
||||
case Torrent::REJECTED:
|
||||
case ModerationStatus::REJECTED:
|
||||
$torrent->update([
|
||||
'status' => Torrent::REJECTED,
|
||||
'status' => ModerationStatus::REJECTED,
|
||||
'moderated_at' => now(),
|
||||
'moderated_by' => $staff->id,
|
||||
]);
|
||||
@@ -135,9 +135,9 @@ class ModerationController extends Controller
|
||||
return to_route('staff.moderation.index')
|
||||
->with('success', 'Torrent Rejected');
|
||||
|
||||
case Torrent::POSTPONED:
|
||||
case ModerationStatus::POSTPONED:
|
||||
$torrent->update([
|
||||
'status' => Torrent::POSTPONED,
|
||||
'status' => ModerationStatus::POSTPONED,
|
||||
'moderated_at' => now(),
|
||||
'moderated_by' => $staff->id,
|
||||
]);
|
||||
|
||||
@@ -29,6 +29,7 @@ use App\Achievements\UserUploaded700Subtitles;
|
||||
use App\Achievements\UserUploaded800Subtitles;
|
||||
use App\Achievements\UserUploaded900Subtitles;
|
||||
use App\Achievements\UserUploadedFirstSubtitle;
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Http\Requests\StoreSubtitleRequest;
|
||||
use App\Http\Requests\UpdateSubtitleRequest;
|
||||
use App\Models\MediaLanguage;
|
||||
@@ -91,7 +92,7 @@ class SubtitleController extends Controller
|
||||
'downloads' => 0,
|
||||
'verified' => 0,
|
||||
'user_id' => $user->id,
|
||||
'status' => Subtitle::APPROVED,
|
||||
'status' => ModerationStatus::APPROVED,
|
||||
'moderated_at' => now(),
|
||||
'moderated_by' => User::SYSTEM_USER_ID,
|
||||
] + $request->safe()->except('subtitle_file'));
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\Bencode;
|
||||
use App\Helpers\MediaInfo;
|
||||
use App\Helpers\TorrentHelper;
|
||||
@@ -150,7 +151,7 @@ class TorrentController extends Controller
|
||||
|| (
|
||||
$user->id === $torrent->user_id
|
||||
&& (
|
||||
$torrent->status !== Torrent::APPROVED
|
||||
$torrent->status !== ModerationStatus::APPROVED
|
||||
|| now()->isBefore($torrent->created_at->addDay())
|
||||
)
|
||||
),
|
||||
@@ -217,7 +218,7 @@ class TorrentController extends Controller
|
||||
|| (
|
||||
$user->id === $torrent->user_id
|
||||
&& (
|
||||
$torrent->status !== Torrent::APPROVED
|
||||
$torrent->status !== ModerationStatus::APPROVED
|
||||
|| now()->isBefore($torrent->created_at->addDay())
|
||||
)
|
||||
),
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\Bencode;
|
||||
use App\Models\Scopes\ApprovedScope;
|
||||
use App\Models\Torrent;
|
||||
@@ -63,7 +64,7 @@ class TorrentDownloadController extends Controller
|
||||
}
|
||||
|
||||
// Torrent Status Is Rejected
|
||||
if ($torrent->status === Torrent::REJECTED) {
|
||||
if ($torrent->status === ModerationStatus::REJECTED) {
|
||||
return to_route('torrents.show', ['id' => $torrent->id])
|
||||
->withErrors('This Torrent Has Been Rejected By Staff');
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Scopes\ApprovedScope;
|
||||
use App\Models\Torrent;
|
||||
|
||||
@@ -26,8 +27,8 @@ class TorrentPendingController extends Controller
|
||||
return view('torrent.pending', [
|
||||
'torrents' => Torrent::withoutGlobalScope(ApprovedScope::class)
|
||||
->with(['category', 'type', 'resolution'])
|
||||
->where('status', '=', Torrent::PENDING)
|
||||
->orWhere('status', '=', Torrent::POSTPONED)
|
||||
->where('status', '=', ModerationStatus::PENDING)
|
||||
->orWhere('status', '=', ModerationStatus::POSTPONED)
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\BonTransactions;
|
||||
use App\Models\Donation;
|
||||
@@ -118,7 +119,7 @@ class UserController extends Controller
|
||||
->first(),
|
||||
'watch' => $user->watchlist,
|
||||
'externalUser' => ! $user->trashed() && $request->user()->group->is_modo ? Unit3dAnnounce::getUser($user->id) : false,
|
||||
'donation' => Donation::where('status', '=', Donation::APPROVED)->where('user_id', '=', $user->id)->latest()->first(),
|
||||
'donation' => Donation::where('status', '=', ModerationStatus::APPROVED)->where('user_id', '=', $user->id)->latest()->first(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Application;
|
||||
use App\Traits\LivewireSort;
|
||||
use Livewire\Attributes\Computed;
|
||||
@@ -58,9 +59,9 @@ class ApplicationSearch extends Component
|
||||
'urlProofs'
|
||||
])
|
||||
->when($this->email, fn ($query) => $query->where('email', 'LIKE', '%'.$this->email.'%'))
|
||||
->when($this->status === '1', fn ($query) => $query->where('status', '=', Application::APPROVED))
|
||||
->when($this->status === '0', fn ($query) => $query->where('status', '=', Application::PENDING))
|
||||
->when($this->status === '2', fn ($query) => $query->where('status', '=', Application::REJECTED))
|
||||
->when($this->status === '1', fn ($query) => $query->where('status', '=', ModerationStatus::APPROVED))
|
||||
->when($this->status === '0', fn ($query) => $query->where('status', '=', ModerationStatus::PENDING))
|
||||
->when($this->status === '2', fn ($query) => $query->where('status', '=', ModerationStatus::REJECTED))
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use App\Achievements\UserMade800Comments;
|
||||
use App\Achievements\UserMade900Comments;
|
||||
use App\Achievements\UserMadeComment;
|
||||
use App\Achievements\UserMadeTenComments;
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Article;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Playlist;
|
||||
@@ -133,7 +134,7 @@ class Comment extends Component
|
||||
{
|
||||
abort_unless($this->model instanceof Ticket || (auth()->user()->can_comment ?? auth()->user()->group->can_comment), 403, __('comment.rights-revoked'));
|
||||
|
||||
abort_if($this->model instanceof Torrent && $this->model->status !== Torrent::APPROVED, 403, __('comment.torrent-status'));
|
||||
abort_if($this->model instanceof Torrent && $this->model->status !== ModerationStatus::APPROVED, 403, __('comment.torrent-status'));
|
||||
|
||||
abort_if($this->comment->isChild(), 403);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use App\Achievements\UserMade800Comments;
|
||||
use App\Achievements\UserMade900Comments;
|
||||
use App\Achievements\UserMadeComment;
|
||||
use App\Achievements\UserMadeTenComments;
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Article;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Playlist;
|
||||
@@ -114,7 +115,7 @@ class Comments extends Component
|
||||
// Authorization
|
||||
abort_unless($this->model instanceof Ticket || ($this->user->can_comment ?? $this->user->group->can_comment), 403, __('comment.rights-revoked'));
|
||||
|
||||
abort_if($this->model instanceof Torrent && $this->model->status !== Torrent::APPROVED, 403, __('comment.torrent-status'));
|
||||
abort_if($this->model instanceof Torrent && $this->model->status !== ModerationStatus::APPROVED, 403, __('comment.torrent-status'));
|
||||
|
||||
// Validation
|
||||
$this->validate();
|
||||
|
||||
@@ -16,7 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Staff;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Rules\EmailBlacklist;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -26,13 +26,13 @@ class ApproveApplicationRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<\Illuminate\Validation\ConditionalRules|\Illuminate\Validation\Rules\In|string>|string>
|
||||
* @return array<string, array<\Illuminate\Validation\ConditionalRules|\Illuminate\Validation\Rules\Enum|string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'status' => [
|
||||
Rule::in([Application::APPROVED]),
|
||||
Rule::enum(ModerationStatus::class)->only([ModerationStatus::APPROVED]),
|
||||
],
|
||||
'email' => [
|
||||
'required',
|
||||
|
||||
@@ -16,7 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Staff;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Enums\ModerationStatus;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -25,13 +25,13 @@ class RejectApplicationRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|\Illuminate\Validation\Rules\In>>
|
||||
* @return array<string, array<string|\Illuminate\Validation\Rules\Enum>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'status' => [
|
||||
Rule::in([Application::REJECTED]),
|
||||
Rule::enum(ModerationStatus::class)->only([ModerationStatus::REJECTED]),
|
||||
],
|
||||
'deny' => [
|
||||
'required',
|
||||
|
||||
@@ -16,7 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Staff;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Enums\ModerationStatus;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -34,21 +34,21 @@ class UpdateModerationRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<int, \Illuminate\Validation\Rules\In|\Illuminate\Validation\Rules\RequiredIf|string>>
|
||||
* @return array<string, array<int, \Illuminate\Validation\Rules\Enum|\Illuminate\Validation\Rules\RequiredIf|string>>
|
||||
*/
|
||||
public function rules(Request $request): array
|
||||
{
|
||||
return [
|
||||
'old_status' => [
|
||||
'required',
|
||||
Rule::in([Torrent::PENDING, Torrent::APPROVED, Torrent::REJECTED, Torrent::POSTPONED]),
|
||||
Rule::enum(ModerationStatus::class),
|
||||
],
|
||||
'status' => [
|
||||
'required',
|
||||
Rule::in([Torrent::APPROVED, Torrent::REJECTED, Torrent::POSTPONED]),
|
||||
Rule::enum(ModerationStatus::class)->only([ModerationStatus::APPROVED, ModerationStatus::REJECTED, ModerationStatus::POSTPONED]),
|
||||
],
|
||||
'message' => [
|
||||
Rule::requiredIf(\in_array($request->integer('status'), [Torrent::REJECTED, Torrent::POSTPONED])),
|
||||
Rule::requiredIf(\in_array($request->integer('status'), [ModerationStatus::REJECTED->value, ModerationStatus::POSTPONED], true)),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\Bencode;
|
||||
use App\Helpers\TorrentTools;
|
||||
use App\Models\Category;
|
||||
@@ -79,11 +80,10 @@ class StoreTorrentRequest extends FormRequest
|
||||
|
||||
if ($torrent !== null) {
|
||||
match ($torrent->status) {
|
||||
Torrent::PENDING => $fail('A torrent with the same info_hash has already been uploaded and is pending moderation.'),
|
||||
Torrent::APPROVED => $fail('A torrent with the same info_hash has already been uploaded and has been approved.'),
|
||||
Torrent::REJECTED => $fail('A torrent with the same info_hash has already been uploaded and has been rejected.'),
|
||||
Torrent::POSTPONED => $fail('A torrent with the same info_hash has already been uploaded and is currently postponed.'),
|
||||
default => null,
|
||||
ModerationStatus::PENDING => $fail('A torrent with the same info_hash has already been uploaded and is pending moderation.'),
|
||||
ModerationStatus::APPROVED => $fail('A torrent with the same info_hash has already been uploaded and has been approved.'),
|
||||
ModerationStatus::REJECTED => $fail('A torrent with the same info_hash has already been uploaded and has been rejected.'),
|
||||
ModerationStatus::POSTPONED => $fail('A torrent with the same info_hash has already been uploaded and is currently postponed.'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Scopes\ApprovedScope;
|
||||
use App\Traits\Auditable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -28,7 +29,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string $type
|
||||
* @property string $email
|
||||
* @property string|null $referrer
|
||||
* @property int $status
|
||||
* @property ModerationStatus $status
|
||||
* @property \Illuminate\Support\Carbon|null $moderated_at
|
||||
* @property int|null $moderated_by
|
||||
* @property int|null $accepted_by
|
||||
@@ -42,19 +43,16 @@ class Application extends Model
|
||||
/** @use HasFactory<\Database\Factories\ApplicationFactory> */
|
||||
use HasFactory;
|
||||
|
||||
final public const PENDING = 0;
|
||||
final public const APPROVED = 1;
|
||||
final public const REJECTED = 2;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array{moderated_at: 'datetime'}
|
||||
* @return array{moderated_at: 'datetime', status: class-string<ModerationStatus>}
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'moderated_at' => 'datetime',
|
||||
'status' => ModerationStatus::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Traits\Encryptable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -25,7 +26,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $gifted_user_id
|
||||
* @property int $status
|
||||
* @property ModerationStatus $status
|
||||
* @property int $package_id
|
||||
* @property string $transaction
|
||||
* @property bool $is_gifted
|
||||
@@ -45,14 +46,14 @@ class Donation extends Model
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array{user_id: 'int', gifted_user_id: 'int', status: 'int', package_id: 'int', transaction: 'string', is_gifted: 'bool', starts_at: 'datetime', ends_at: 'datetime', created_at: 'datetime', updated_at: 'datetime'}
|
||||
* @return array{user_id: 'int', gifted_user_id: 'int', status: class-string<ModerationStatus>, package_id: 'int', transaction: 'string', is_gifted: 'bool', starts_at: 'datetime', ends_at: 'datetime', created_at: 'datetime', updated_at: 'datetime'}
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'int',
|
||||
'gifted_user_id' => 'int',
|
||||
'status' => 'int',
|
||||
'status' => ModerationStatus::class,
|
||||
'package_id' => 'int',
|
||||
'transaction' => 'string',
|
||||
'is_gifted' => 'bool',
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Scopes;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Torrent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -30,6 +31,6 @@ class ApprovedScope implements Scope
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model): void
|
||||
{
|
||||
$builder->where('status', '=', Torrent::APPROVED);
|
||||
$builder->where('status', '=', ModerationStatus::APPROVED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Models\Scopes\ApprovedScope;
|
||||
@@ -37,7 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $user_id
|
||||
* @property int $torrent_id
|
||||
* @property bool $anon
|
||||
* @property int $status
|
||||
* @property ModerationStatus $status
|
||||
* @property \Illuminate\Support\Carbon|null $moderated_at
|
||||
* @property int|null $moderated_by
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
@@ -50,19 +51,18 @@ class Subtitle extends Model
|
||||
/** @use HasFactory<\Database\Factories\SubtitleFactory> */
|
||||
use HasFactory;
|
||||
|
||||
final public const APPROVED = 1;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array{anon: 'bool', moderated_at: 'datetime'}
|
||||
* @return array{anon: 'bool', status: class-string<ModerationStatus>, moderated_at: 'datetime'}
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'anon' => 'bool',
|
||||
'status' => ModerationStatus::class,
|
||||
'moderated_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Helpers\StringHelper;
|
||||
use App\Models\Scopes\ApprovedScope;
|
||||
use App\Notifications\NewComment;
|
||||
@@ -59,7 +60,7 @@ use Laravel\Scout\Searchable;
|
||||
* @property bool $doubleup
|
||||
* @property bool $refundable
|
||||
* @property int $highspeed
|
||||
* @property int $status
|
||||
* @property ModerationStatus $status
|
||||
* @property \Illuminate\Support\Carbon|null $moderated_at
|
||||
* @property int|null $moderated_by
|
||||
* @property bool $anon
|
||||
@@ -98,6 +99,7 @@ class Torrent extends Model
|
||||
* @return array{
|
||||
* tmdb: 'int',
|
||||
* igdb: 'int',
|
||||
* status: class-string<ModerationStatus>,
|
||||
* bumped_at: 'datetime',
|
||||
* fl_until: 'datetime',
|
||||
* du_until: 'datetime',
|
||||
@@ -122,6 +124,7 @@ class Torrent extends Model
|
||||
'moderated_at' => 'datetime',
|
||||
'anon' => 'bool',
|
||||
'sticky' => 'bool',
|
||||
'status' => ModerationStatus::class,
|
||||
'personal_release' => 'bool',
|
||||
];
|
||||
}
|
||||
@@ -135,11 +138,6 @@ class Torrent extends Model
|
||||
'info_hash',
|
||||
];
|
||||
|
||||
final public const PENDING = 0;
|
||||
final public const APPROVED = 1;
|
||||
final public const REJECTED = 2;
|
||||
final public const POSTPONED = 3;
|
||||
|
||||
/**
|
||||
* This query is to be added to a raw select from the torrents table.
|
||||
*
|
||||
@@ -926,7 +924,7 @@ class Torrent extends Model
|
||||
'refundable' => (bool) $torrent->refundable,
|
||||
'highspeed' => (bool) $torrent->highspeed,
|
||||
'featured' => (bool) $torrent->featured,
|
||||
'status' => $torrent->status,
|
||||
'status' => $torrent->status->value,
|
||||
'anon' => (bool) $torrent->anon,
|
||||
'sticky' => (int) $torrent->sticky,
|
||||
'sd' => (bool) $torrent->sd,
|
||||
|
||||
@@ -81,7 +81,7 @@ class Unit3dAnnounce
|
||||
{
|
||||
return self::put('torrents', [
|
||||
'id' => $torrent->id,
|
||||
'status' => $torrent->status,
|
||||
'status' => $torrent->status->value,
|
||||
'info_hash' => bin2hex($torrent->info_hash),
|
||||
'is_deleted' => false,
|
||||
'seeders' => $torrent->seeders,
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\View\Composers;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Donation;
|
||||
use App\Models\Event;
|
||||
use App\Models\Page;
|
||||
@@ -56,7 +57,7 @@ class TopNavComposer
|
||||
$sum = Donation::query()
|
||||
->join('donation_packages', 'donations.package_id', '=', 'donation_packages.id')
|
||||
->where('donations.created_at', '>=', now()->startOfMonth())
|
||||
->where('donations.status', Donation::APPROVED)
|
||||
->where('donations.status', ModerationStatus::APPROVED)
|
||||
->sum('donation_packages.cost');
|
||||
|
||||
return $sum ? min(100, number_format(($sum / config('donation.monthly_goal')) * 100)) : 0;
|
||||
@@ -79,7 +80,7 @@ class TopNavComposer
|
||||
'hasUnmoderatedTorrent' => $user->group->is_torrent_modo
|
||||
? Torrent::query()
|
||||
->withoutGlobalScope(ApprovedScope::class)
|
||||
->where('status', '=', Torrent::PENDING)
|
||||
->where('status', '=', ModerationStatus::PENDING)
|
||||
->exists()
|
||||
: false,
|
||||
'hasUnreadPm' => $user->participations()->where('read', '=', false)->exists(),
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Category;
|
||||
use App\Models\Resolution;
|
||||
use App\Models\Torrent;
|
||||
@@ -64,7 +65,7 @@ class TorrentFactory extends Factory
|
||||
'free' => $freeleech[$selected],
|
||||
'doubleup' => $this->faker->boolean(),
|
||||
'highspeed' => $this->faker->boolean(),
|
||||
'status' => Torrent::APPROVED,
|
||||
'status' => ModerationStatus::APPROVED,
|
||||
'moderated_at' => now(),
|
||||
'moderated_by' => 1,
|
||||
'anon' => $this->faker->boolean(),
|
||||
|
||||
@@ -90,15 +90,15 @@
|
||||
<dt>{{ __('common.status') }}</dt>
|
||||
<dd>
|
||||
@switch($application->status)
|
||||
@case(\App\Models\Application::PENDING)
|
||||
@case(\App\Enums\ModerationStatus::PENDING)
|
||||
<span class="application--pending">Pending</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Application::APPROVED)
|
||||
@case(\App\Enums\ModerationStatus::APPROVED)
|
||||
<span class="application--approved">Approved</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Application::REJECTED)
|
||||
@case(\App\Enums\ModerationStatus::REJECTED)
|
||||
<span class="application--rejected">Rejected</span>
|
||||
|
||||
@break
|
||||
@@ -110,7 +110,7 @@
|
||||
</dl>
|
||||
</section>
|
||||
<section class="panelV2">
|
||||
@if ($application->status !== \App\Models\Application::PENDING)
|
||||
@if ($application->status !== \App\Enums\ModerationStatus::PENDING)
|
||||
<h2 class="panel__heading">{{ __('common.moderated-by') }}</h2>
|
||||
<div class="panel__body">
|
||||
<x-user_tag :anon="false" :user="$application->moderated" />
|
||||
|
||||
@@ -89,9 +89,9 @@
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if ($donation->status === App\Models\Donation::PENDING)
|
||||
@if ($donation->status === App\Enums\ModerationStatus::PENDING)
|
||||
<span class="text-warning">Pending</span>
|
||||
@elseif ($donation->status === App\Models\Donation::APPROVED)
|
||||
@elseif ($donation->status === App\Enums\ModerationStatus::APPROVED)
|
||||
<span class="text-success">Approved</span>
|
||||
@else
|
||||
<span class="text-danger">Rejected</span>
|
||||
@@ -99,7 +99,7 @@
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if ($donation->status === App\Models\Donation::PENDING)
|
||||
@if ($donation->status === App\Enums\ModerationStatus::PENDING)
|
||||
<menu class="data-table__actions">
|
||||
<li class="data-table__action">
|
||||
<form
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Models\Torrent::APPROVED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::APPROVED }}"
|
||||
/>
|
||||
<button class="form__button form__button--filled">
|
||||
<i
|
||||
@@ -166,7 +166,7 @@
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Models\Torrent::APPROVED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::APPROVED }}"
|
||||
/>
|
||||
<button class="form__button form__button--filled">
|
||||
<i
|
||||
@@ -264,7 +264,7 @@
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Models\Torrent::APPROVED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::APPROVED }}"
|
||||
/>
|
||||
<button class="form__button form__button--filled">
|
||||
<i
|
||||
|
||||
@@ -18,7 +18,11 @@
|
||||
<input type="hidden" name="type" value="{{ __('torrent.torrent') }}" />
|
||||
<input type="hidden" name="id" value="{{ $torrent->id }}" />
|
||||
<input type="hidden" name="old_status" value="{{ $torrent->status }}" />
|
||||
<input type="hidden" name="status" value="{{ \App\Models\Torrent::POSTPONED }}" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Enums\ModerationStatus::POSTPONED }}"
|
||||
/>
|
||||
<p class="form__group">
|
||||
<textarea class="form__textarea" name="message" id="message">
|
||||
{{ old('message') }}</textarea
|
||||
|
||||
@@ -18,7 +18,11 @@
|
||||
<input id="type" type="hidden" name="type" value="{{ __('torrent.torrent') }}" />
|
||||
<input id="id" type="hidden" name="id" value="{{ $torrent->id }}" />
|
||||
<input type="hidden" name="old_status" value="{{ $torrent->status }}" />
|
||||
<input type="hidden" name="status" value="{{ \App\Models\Torrent::REJECTED }}" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Enums\ModerationStatus::REJECTED }}"
|
||||
/>
|
||||
<p class="form__group">
|
||||
<textarea id="message" class="form__textarea" name="message">
|
||||
{{ old('message') }}</textarea
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
"
|
||||
>
|
||||
@foreach ($featured as $feature)
|
||||
@if ($feature->torrent === null || $feature->torrent->status !== \App\Models\Torrent::APPROVED)
|
||||
@if ($feature->torrent === null || $feature->torrent->status !== \App\Enums\ModerationStatus::APPROVED)
|
||||
@continue
|
||||
@endif
|
||||
|
||||
|
||||
@@ -83,15 +83,15 @@
|
||||
</td>
|
||||
<td>
|
||||
@switch($application->status)
|
||||
@case(\App\Models\Application::PENDING)
|
||||
@case(\App\Enums\ModerationStatus::PENDING)
|
||||
<span class="application--pending">Pending</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Application::APPROVED)
|
||||
@case(\App\Enums\ModerationStatus::APPROVED)
|
||||
<span class="application--approved">Approved</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Application::REJECTED)
|
||||
@case(\App\Enums\ModerationStatus::REJECTED)
|
||||
<span class="application--rejected">Rejected</span>
|
||||
|
||||
@break
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
<input
|
||||
class="user-torrents__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::PENDING }}"
|
||||
value="{{ \App\Enums\ModerationStatus::PENDING }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
{{ __('torrent.pending') }}
|
||||
@@ -196,7 +196,7 @@
|
||||
<input
|
||||
class="user-torrents__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::APPROVED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::APPROVED }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
{{ __('torrent.approved') }}
|
||||
@@ -207,7 +207,7 @@
|
||||
<input
|
||||
class="user-torrents__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::REJECTED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::REJECTED }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
{{ __('torrent.rejected') }}
|
||||
@@ -218,7 +218,7 @@
|
||||
<input
|
||||
class="user-torrents__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::POSTPONED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::POSTPONED }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
Postponed
|
||||
@@ -701,28 +701,28 @@
|
||||
</td>
|
||||
<td class="user-torrents__status">
|
||||
@switch($history->status)
|
||||
@case(\App\Models\Torrent::PENDING)
|
||||
@case(\App\Enums\ModerationStatus::PENDING)
|
||||
<span
|
||||
title="{{ __('torrent.pending') }}"
|
||||
class="{{ config('other.font-awesome') }} fa-tasks text-orange"
|
||||
></span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::APPROVED)
|
||||
@case(\App\Enums\ModerationStatus::APPROVED)
|
||||
<span
|
||||
title="{{ __('torrent.approved') }}"
|
||||
class="{{ config('other.font-awesome') }} fa-check text-green"
|
||||
></span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::REJECTED)
|
||||
@case(\App\Enums\ModerationStatus::REJECTED)
|
||||
<span
|
||||
title="{{ __('torrent.rejected') }}"
|
||||
class="{{ config('other.font-awesome') }} fa-times text-red"
|
||||
></span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::POSTPONED)
|
||||
@case(\App\Enums\ModerationStatus::POSTPONED)
|
||||
<span
|
||||
title="Postponed"
|
||||
class="{{ config('other.font-awesome') }} fa-hourglass text-red"
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<input
|
||||
class="user-uploads__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::PENDING }}"
|
||||
value="{{ \App\Enums\ModerationStatus::PENDING }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
{{ __('torrent.pending') }}
|
||||
@@ -63,7 +63,7 @@
|
||||
<input
|
||||
class="user-uploads__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::APPROVED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::APPROVED }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
{{ __('torrent.approved') }}
|
||||
@@ -74,7 +74,7 @@
|
||||
<input
|
||||
class="user-uploads__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::REJECTED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::REJECTED }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
{{ __('torrent.rejected') }}
|
||||
@@ -85,7 +85,7 @@
|
||||
<input
|
||||
class="user-uploads__checkbox"
|
||||
type="checkbox"
|
||||
value="{{ \App\Models\Torrent::POSTPONED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::POSTPONED }}"
|
||||
wire:model.live="status"
|
||||
/>
|
||||
Postponed
|
||||
@@ -300,28 +300,28 @@
|
||||
</td>
|
||||
<td class="user-uploads__status">
|
||||
@switch($torrent->status)
|
||||
@case(\App\Models\Torrent::PENDING)
|
||||
@case(\App\Enums\ModerationStatus::PENDING)
|
||||
<span
|
||||
title="{{ __('torrent.pending') }}"
|
||||
class="{{ config('other.font-awesome') }} fa-tasks text-orange"
|
||||
></span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::APPROVED)
|
||||
@case(\App\Enums\ModerationStatus::APPROVED)
|
||||
<span
|
||||
title="{{ __('torrent.approved') }}"
|
||||
class="{{ config('other.font-awesome') }} fa-check text-green"
|
||||
></span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::REJECTED)
|
||||
@case(\App\Enums\ModerationStatus::REJECTED)
|
||||
<span
|
||||
title="{{ __('torrent.rejected') }}"
|
||||
class="{{ config('other.font-awesome') }} fa-times text-red"
|
||||
></span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::POSTPONED)
|
||||
@case(\App\Enums\ModerationStatus::POSTPONED)
|
||||
<span
|
||||
title="Postponed"
|
||||
class="{{ config('other.font-awesome') }} fa-hourglass text-red"
|
||||
|
||||
@@ -116,17 +116,17 @@
|
||||
<div class="key-value__group">
|
||||
<dt>{{ __('torrent.moderation') }}</dt>
|
||||
<dd>
|
||||
@if ($torrent->status === \App\Models\Torrent::REJECTED)
|
||||
@if ($torrent->status === \App\Enums\ModerationStatus::REJECTED)
|
||||
<span class="text-red">
|
||||
<i class="{{ config('other.font-awesome') }} fa-times"></i>
|
||||
{{ strtoupper(__('torrent.rejected')) }}
|
||||
</span>
|
||||
@elseif ($torrent->status === \App\Models\Torrent::PENDING)
|
||||
@elseif ($torrent->status === \App\Enums\ModerationStatus::PENDING)
|
||||
<span class="text-orange">
|
||||
<i class="{{ config('other.font-awesome') }} fa-times"></i>
|
||||
{{ strtoupper(__('torrent.pending')) }}
|
||||
</span>
|
||||
@elseif ($torrent->status === \App\Models\Torrent::POSTPONED)
|
||||
@elseif ($torrent->status === \App\Enums\ModerationStatus::POSTPONED)
|
||||
<span class="text-red">
|
||||
<i class="{{ config('other.font-awesome') }} fa-times"></i>
|
||||
{{ strtoupper(__('torrent.postponed')) }}
|
||||
|
||||
@@ -361,7 +361,7 @@
|
||||
flex-wrap: wrap;
|
||||
"
|
||||
>
|
||||
@if ($torrent->status !== \App\Models\Torrent::APPROVED)
|
||||
@if ($torrent->status !== \App\Enums\ModerationStatus::APPROVED)
|
||||
<li>
|
||||
<form
|
||||
role="form"
|
||||
@@ -378,7 +378,7 @@
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Models\Torrent::APPROVED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::APPROVED }}"
|
||||
/>
|
||||
<button class="form__button form__button--outlined">
|
||||
<i class="{{ config('other.font-awesome') }} fa-thumbs-up"></i>
|
||||
@@ -388,7 +388,7 @@
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@if ($torrent->status !== \App\Models\Torrent::POSTPONED)
|
||||
@if ($torrent->status !== \App\Enums\ModerationStatus::POSTPONED)
|
||||
<li x-data="dialog">
|
||||
<button
|
||||
class="form__button form__button--outlined"
|
||||
@@ -428,7 +428,7 @@
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Models\Torrent::POSTPONED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::POSTPONED }}"
|
||||
/>
|
||||
<p class="form__group">
|
||||
<textarea
|
||||
@@ -461,7 +461,7 @@
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@if ($torrent->status !== \App\Models\Torrent::REJECTED)
|
||||
@if ($torrent->status !== \App\Enums\ModerationStatus::REJECTED)
|
||||
<li x-data="dialog">
|
||||
<button
|
||||
class="form__button form__button--outlined"
|
||||
@@ -503,7 +503,7 @@
|
||||
<input
|
||||
type="hidden"
|
||||
name="status"
|
||||
value="{{ \App\Models\Torrent::REJECTED }}"
|
||||
value="{{ \App\Enums\ModerationStatus::REJECTED }}"
|
||||
/>
|
||||
<p class="form__group">
|
||||
<textarea
|
||||
@@ -538,17 +538,17 @@
|
||||
|
||||
<li>
|
||||
@switch($torrent->status)
|
||||
@case(\App\Models\Torrent::APPROVED)
|
||||
@case(\App\Enums\ModerationStatus::APPROVED)
|
||||
Approved By:
|
||||
<x-user_tag :user="$torrent->moderated" :anon="false" />
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::POSTPONED)
|
||||
@case(\App\Enums\ModerationStatus::POSTPONED)
|
||||
Postponed By:
|
||||
<x-user_tag :user="$torrent->moderated" :anon="false" />
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::REJECTED)
|
||||
@case(\App\Enums\ModerationStatus::REJECTED)
|
||||
Rejected By:
|
||||
<x-user_tag :user="$torrent->moderated" :anon="false" />
|
||||
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
<td>{{ $torrent->created_at->diffForHumans() }}</td>
|
||||
<td>
|
||||
@switch($torrent->status)
|
||||
@case(\App\Models\Torrent::PENDING)
|
||||
@case(\App\Enums\ModerationStatus::PENDING)
|
||||
<span class="torrent--pending">
|
||||
{{ __('torrent.pending') }}
|
||||
</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Torrent::POSTPONED)
|
||||
@case(\App\Enums\ModerationStatus::POSTPONED)
|
||||
<span class="torrent--postponed">
|
||||
{{ __('torrent.postponed') }}
|
||||
</span>
|
||||
|
||||
@@ -374,15 +374,15 @@
|
||||
</td>
|
||||
<td>
|
||||
@switch($user->application->status)
|
||||
@case(\App\Models\Application::PENDING)
|
||||
@case(\App\Enums\ModerationStatus::PENDING)
|
||||
<span class="application--pending">Pending</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Application::APPROVED)
|
||||
@case(\App\Enums\ModerationStatus::APPROVED)
|
||||
<span class="application--approved">Approved</span>
|
||||
|
||||
@break
|
||||
@case(\App\Models\Application::REJECTED)
|
||||
@case(\App\Enums\ModerationStatus::REJECTED)
|
||||
<span class="application--rejected">Rejected</span>
|
||||
|
||||
@break
|
||||
|
||||
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
@@ -29,7 +30,7 @@ test('index returns an ok response', function (): void {
|
||||
|
||||
Torrent::factory()->create([
|
||||
'info_hash' => $info_hash,
|
||||
'status' => Torrent::APPROVED,
|
||||
'status' => ModerationStatus::APPROVED,
|
||||
]);
|
||||
|
||||
$headers = [
|
||||
|
||||
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Http\Controllers\Staff\ApplicationController;
|
||||
use App\Http\Livewire\ApplicationSearch;
|
||||
use App\Http\Requests\Staff\ApproveApplicationRequest;
|
||||
@@ -42,11 +43,11 @@ test('approve validates with a form request', function (): void {
|
||||
|
||||
test('approve returns an ok response', function (): void {
|
||||
$application = Application::factory()->create([
|
||||
'status' => Application::PENDING,
|
||||
'status' => ModerationStatus::PENDING,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->staffUser)->post(route('staff.applications.approve', ['id' => $application->id]), [
|
||||
'status' => Application::APPROVED,
|
||||
'status' => ModerationStatus::APPROVED->value,
|
||||
'moderated_by' => $this->staffUser->id,
|
||||
'moderated_at' => now(),
|
||||
'approve' => 'Approved',
|
||||
@@ -73,11 +74,11 @@ test('reject validates with a form request', function (): void {
|
||||
|
||||
test('reject returns an ok response', function (): void {
|
||||
$application = Application::factory()->create([
|
||||
'status' => Application::PENDING,
|
||||
'status' => ModerationStatus::PENDING,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->staffUser)->post(route('staff.applications.reject', ['id' => $application->id]), [
|
||||
'status' => Application::REJECTED,
|
||||
'status' => ModerationStatus::REJECTED->value,
|
||||
'moderated_by' => $this->staffUser->id,
|
||||
'moderated_at' => now(),
|
||||
'deny' => 'Denied',
|
||||
@@ -88,7 +89,7 @@ test('reject returns an ok response', function (): void {
|
||||
|
||||
test('show returns an ok response', function (): void {
|
||||
$application = Application::factory()->create([
|
||||
'status' => Application::APPROVED,
|
||||
'status' => ModerationStatus::APPROVED,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->staffUser)->get(route('staff.applications.show', ['id' => $application->id]));
|
||||
|
||||
@@ -16,6 +16,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Old;
|
||||
|
||||
use App\Enums\ModerationStatus;
|
||||
use App\Models\Category;
|
||||
use App\Models\Resolution;
|
||||
use App\Models\Torrent;
|
||||
@@ -95,7 +96,7 @@ final class TorrentControllerTest extends TestCase
|
||||
|
||||
$torrent = Torrent::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'status' => Torrent::APPROVED,
|
||||
'status' => ModerationStatus::APPROVED,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user, 'api')->getJson(\sprintf('api/torrents/%s', $torrent->id));
|
||||
|
||||
Reference in New Issue
Block a user