Skip to content

Commit

Permalink
tests: fixed submission rule (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Jul 29, 2024
1 parent c02840a commit 89fe315
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/Enums/Models/Wiki/ResourceSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static function parseIdFromLink(string $link): ?string
ResourceSite::NETFLIX,
ResourceSite::LIVECHART,
ResourceSite::APPLE_MUSIC => Str::match('/\d+/', $link),
// ResourceSite::ANIME_PLANET => ResourceSite::parseAnimePlanetIdFromLink($link),
ResourceSite::ANIME_PLANET => ResourceSite::parseAnimePlanetIdFromLink($link),
ResourceSite::KITSU => ResourceSite::parseKitsuIdFromLink($link),
default => null,
};
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/Admin/FeaturePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function view(?User $user, Feature $feature): bool
return $user !== null && $user->can(CrudPermission::VIEW->format(Feature::class));
}

return true;
return $feature->isNullScope();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/Admin/FeaturedThemePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function view(?User $user, FeaturedTheme $featuredtheme): bool
return $user !== null && $user->can(CrudPermission::VIEW->format(FeaturedTheme::class));
}

return true;
return $featuredtheme->start_at->isBefore(Date::now());
}

/**
Expand Down
38 changes: 19 additions & 19 deletions app/Rules/Wiki/Submission/SubmissionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ abstract class SubmissionRule implements ValidationRule, ValidatorAwareRule
*/
public function setValidator(Validator $validator): self
{
/** @var UploadedFile|array $files */
$files = Arr::get($validator->getData(), 'file');

foreach ($files as $file) {
/** @var UploadedFile $file*/

$ffprobeData = Arr::get($validator->getData(), 'ffprobeData');
if ($ffprobeData === null && $file !== null) {
$ffprobeData = $this->getFFprobeData($file);
$validator->setValue('ffprobeData', $ffprobeData);
}
static::$ffprobeData = $ffprobeData;

$loudnessStats = Arr::get($validator->getData(), 'loudnessStats');
if ($loudnessStats === null && $file !== null) {
$loudnessStats = $this->getLoudnessStats($file);
$validator->setValue('loudnessStats', $loudnessStats);
}
$this->loudnessStats = $loudnessStats;
/** @var UploadedFile|array $file */
$file = Arr::get($validator->getData(), 'file');

if (is_array($file)) {
$file = Arr::first($file);
}

$ffprobeData = Arr::get($validator->getData(), 'ffprobeData');
if ($ffprobeData === null && $file !== null) {
$ffprobeData = $this->getFFprobeData($file);
$validator->setValue('ffprobeData', $ffprobeData);
}
static::$ffprobeData = $ffprobeData;

$loudnessStats = Arr::get($validator->getData(), 'loudnessStats');
if ($loudnessStats === null && $file !== null) {
$loudnessStats = $this->getLoudnessStats($file);
$validator->setValue('loudnessStats', $loudnessStats);
}
$this->loudnessStats = $loudnessStats;

return $this;
}
Expand Down

0 comments on commit 89fe315

Please sign in to comment.