mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-28 07:37:59 +01:00
Merge pull request #125 from Lavoaster/fix-validation
Fix API track validation
This commit is contained in:
commit
79ac83c8e3
1 changed files with 10 additions and 2 deletions
|
@ -145,7 +145,9 @@ class UploadTrackCommand extends CommandBase
|
||||||
|
|
||||||
$input = Request::all();
|
$input = Request::all();
|
||||||
$input['track'] = $trackFile;
|
$input['track'] = $trackFile;
|
||||||
if (!$this->_isReplacingTrack) {
|
|
||||||
|
// Prevent the setting of the cover index for validation
|
||||||
|
if (!$this->_isReplacingTrack && isset($coverFile)) {
|
||||||
$input['cover'] = $coverFile;
|
$input['cover'] = $coverFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +161,7 @@ class UploadTrackCommand extends CommandBase
|
||||||
. 'audio_channels:1,2',
|
. 'audio_channels:1,2',
|
||||||
];
|
];
|
||||||
if (!$this->_isReplacingTrack) {
|
if (!$this->_isReplacingTrack) {
|
||||||
array_push($rules, [
|
array_merge($rules, [
|
||||||
'cover' => 'image|mimes:png,jpeg|min_width:350|min_height:350',
|
'cover' => 'image|mimes:png,jpeg|min_width:350|min_height:350',
|
||||||
'auto_publish' => 'boolean',
|
'auto_publish' => 'boolean',
|
||||||
'title' => 'string',
|
'title' => 'string',
|
||||||
|
@ -198,6 +200,12 @@ class UploadTrackCommand extends CommandBase
|
||||||
$this->_track->source = $this->_customTrackSource ?? $source;
|
$this->_track->source = $this->_customTrackSource ?? $source;
|
||||||
$this->_track->save();
|
$this->_track->save();
|
||||||
|
|
||||||
|
// If the cover was null, and not included, add it back in as null so that
|
||||||
|
// other commands do not encounter a undefined index.
|
||||||
|
if (! isset($input['cover'])) {
|
||||||
|
$input['cover'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->_isReplacingTrack) {
|
if (!$this->_isReplacingTrack) {
|
||||||
// Parse any tags in the uploaded files.
|
// Parse any tags in the uploaded files.
|
||||||
$parseTagsCommand = new ParseTrackTagsCommand($this->_track, $trackFile, $input);
|
$parseTagsCommand = new ParseTrackTagsCommand($this->_track, $trackFile, $input);
|
||||||
|
|
Loading…
Reference in a new issue