Skip to content

Commit

Permalink
Merge pull request #4282 from HDInnovations/8.x.x
Browse files Browse the repository at this point in the history
(Release) v8.3.3
  • Loading branch information
HDVinnie authored Oct 27, 2024
2 parents 619c61c + f141fb7 commit 437c8dc
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 385 deletions.
3 changes: 2 additions & 1 deletion app/Console/Commands/AutoRemoveTimedTorrentBuffs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Throwable;

class AutoRemoveTimedTorrentBuffs extends Command
Expand Down Expand Up @@ -71,7 +72,7 @@ final public function handle(): void
}

Torrent::query()->whereNotNull('bumped_at')->where('bumped_at', '<', now()->subWeek())->update([
'bumped_at' => null,
'bumped_at' => DB::raw('created_at'),
]);

$this->comment('Automated Removal Of Expired Torrent Buffs Command Complete');
Expand Down
4 changes: 2 additions & 2 deletions app/DTO/TorrentSearchFiltersDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ final public function toMeilisearchFilter(): array

if ($this->endYear !== null) {
$filters[] = [
'movie.year <= '.$this->startYear,
'tv.year <= '.$this->startYear,
'movie.year <= '.$this->endYear,
'tv.year <= '.$this->endYear,
];
}

Expand Down
4 changes: 3 additions & 1 deletion app/Helpers/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ public static function formatBytes(int|float $bytes = 0, int $precision = 2): st
return $result."\u{a0}".self::units[$i];
}

public static function timeElapsed(int $seconds): string
public static function timeElapsed(int|float $seconds): string
{
$seconds = \intval($seconds);

if ($seconds == 0) {
return 'N/A';
}
Expand Down
5 changes: 0 additions & 5 deletions app/Http/Controllers/API/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ public function createMessage(Request $request): \Illuminate\Contracts\Routing\R
return response('error', 401);
}

// Temp Fix For HTMLPurifier
if ($message === '<') {
return response('error', 401);
}

$bots = cache()->remember('bots', 3600, fn () => Bot::where('active', '=', 1)->orderByDesc('position')->get());

$which = null;
Expand Down
6 changes: 5 additions & 1 deletion app/Http/Controllers/Staff/AuditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\Vie
return view('Staff.audit.index', [
'staffUsers' => User::query()
->with(['group'])
->whereRelation('group', 'is_modo', '=', true)
->whereHas('group', function ($query): void {
$query->where('is_modo', '=', true)
->orWhere('is_editor', '=', true);
})
->withCount([
'audits as total_actions' => fn ($query) => $query->where('action', '!=', 'create'),
'audits as last_60_days' => fn ($query) => $query->where('action', '!=', 'create')->whereBetween('created_at', [now()->subDays(60), now()]),
'audits as last_30_days' => fn ($query) => $query->where('action', '!=', 'create')->whereBetween('created_at', [now()->subDays(30), now()]),
])
->get()
->sortBy(fn ($user) => $user->group->level)
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/PlaylistSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final public function playlists()
->orWhere(fn ($query) => $query->where('is_private', '=', 1)->where('user_id', '=', auth()->id()))
)
)
->when($this->name !== '', fn ($query) => $query->where('name', '=', $this->name))
->when($this->name !== '', fn ($query) => $query->where('name', 'LIKE', '%'.str_replace(' ', '%', $this->name).'%'))
->when($this->username !== '', fn ($query) => $query->whereRelation('user', 'username', '=', $this->username))
->orderBy($this->sortField, $this->sortDirection)
->paginate(min($this->perPage, 100));
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/TorrentSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ final public function torrents(): \Illuminate\Contracts\Pagination\LengthAwarePa
],
'filter' => $this->filters()->toMeilisearchFilter(),
'matchingStrategy' => 'all',
'page' => $this->getPage(),
'page' => (int) $this->getPage(),
'hitsPerPage' => min($this->perPage, 100),
'attributesToRetrieve' => ['id'],
]);
Expand Down
64 changes: 47 additions & 17 deletions app/Http/Requests/UpdateTorrentRequestRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

namespace App\Http\Requests;

use App\Models\Category;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;

class UpdateTorrentRequestRequest extends FormRequest
{
Expand All @@ -31,39 +34,66 @@ public function authorize(): bool
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array<\Illuminate\Contracts\Validation\Rule|string>|string>
* @return array<string, array<\Illuminate\Validation\ConditionalRules|string>|string>
*/
public function rules(): array
public function rules(Request $request): array
{
$category = Category::findOrFail($request->integer('category_id'));

return [
'name' => [
'required',
'max:180',
],
'imdb' => [
'required',
'decimal:0',
'min:0',
Rule::when($category->movie_meta || $category->tv_meta, [
'required',
'decimal:0',
'min:0',
]),
Rule::when(!($category->movie_meta || $category->tv_meta), [
Rule::in([0]),
]),
],
'tvdb' => [
'required',
'decimal:0',
'min:0',
Rule::when($category->tv_meta, [
'required',
'decimal:0',
'min:0',
]),
Rule::when(!$category->tv_meta, [
Rule::in([0]),
]),
],
'tmdb' => [
'required',
'decimal:0',
'min:0',
Rule::when($category->movie_meta || $category->tv_meta, [
'required',
'decimal:0',
'min:0',
]),
Rule::when(!($category->movie_meta || $category->tv_meta), [
Rule::in([0]),
]),
],
'mal' => [
'required',
'decimal:0',
'min:0',
Rule::when($category->movie_meta || $category->tv_meta, [
'required',
'decimal:0',
'min:0',
]),
Rule::when(!($category->movie_meta || $category->tv_meta), [
Rule::in([0]),
]),
],
'igdb' => [
'required',
'decimal:0',
'min:0',
Rule::when($category->game_meta, [
'required',
'decimal:0',
'min:0',
]),
Rule::when(!$category->game_meta, [
Rule::in([0]),
]),
],
'category_id' => [
'required',
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Resources/ChatMessageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Helpers\Bbcode;
use hdvinnie\LaravelJoyPixels\LaravelJoyPixels;
use Illuminate\Http\Resources\Json\JsonResource;
use voku\helper\AntiXSS;

/**
* @mixin \App\Models\Message
Expand All @@ -34,26 +35,24 @@ public function toArray($request): array
{
$emojiOne = app()->make(LaravelJoyPixels::class);

$logger = null;
$bbcode = new Bbcode();

if ($this->user_id == 1) {
$logger = $bbcode->parse('<div class="align-left"><div class="chatTriggers">'.$this->message.'</div></div>');
$logger = $emojiOne->toImage($logger);
$logger = str_replace('a href="/#', 'a trigger="bot" class="chatTrigger" href="/#', (string) $logger);
$logger = str_replace('a href="/#', 'a trigger="bot" class="chatTrigger" href="/#', $logger);
} else {
$logger = $bbcode->parse('<div class="align-left">'.$this->message.'</div>');
$logger = $emojiOne->toImage($logger);
}
$logger = htmlspecialchars_decode((string) $logger);

return [
'id' => $this->id,
'bot' => new BotResource($this->whenLoaded('bot')),
'user' => new ChatUserResource($this->whenLoaded('user')),
'receiver' => new ChatUserResource($this->whenLoaded('receiver')),
'chatroom' => new ChatRoomResource($this->whenLoaded('chatroom')),
'message' => clean($logger),
'message' => (new AntiXSS())->xss_clean($logger),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
];
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ protected function casts(): array
) AS json_tv,
(
SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT(
'id', playlist_torrents.id
'id', playlist_torrents.playlist_id
)), JSON_ARRAY())
FROM playlist_torrents
WHERE torrents.id = playlist_torrents.playlist_id
WHERE torrents.id = playlist_torrents.torrent_id
) AS json_playlists,
(
SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT(
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"doctrine/dbal": "^3.9.3",
"gabrielelana/byte-units": "^0.5.0",
"guzzlehttp/guzzle": "^7.9.2",
"hdvinnie/laravel-html-purifier": "^v3.0.0",
"hdvinnie/laravel-joypixel-emojis": "^v3.0.0",
"hdvinnie/laravel-security-headers": "^v3.0.0",
"intervention/image": "^2.7.2",
Expand Down
133 changes: 1 addition & 132 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 437c8dc

Please sign in to comment.