mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-01-31 03:16:42 +01:00
Fixes T372 for all content types. Also fixes album and playlist downloads following T350.
This commit is contained in:
parent
01ebdf5ac0
commit
5188e4947c
7 changed files with 38 additions and 12 deletions
|
@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Auth;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use App\Traits\SlugTrait;
|
||||
use Helpers;
|
||||
|
||||
class Album extends Model
|
||||
{
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use ZipStream;
|
||||
|
||||
class AlbumDownloader
|
||||
{
|
||||
private $_album;
|
||||
|
@ -50,4 +54,4 @@ class AlbumDownloader
|
|||
$zip->addFile($notes, $directory . 'Album Notes.txt');
|
||||
$zip->finalize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Album;
|
||||
use App\Comment;
|
||||
use App\Playlist;
|
||||
use App\Track;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
|
@ -74,14 +77,27 @@ class CreateCommentCommand extends CommandBase
|
|||
|
||||
$comment->$column = $this->_id;
|
||||
$comment->save();
|
||||
|
||||
|
||||
// Recount the track's comments, if this is a track comment
|
||||
if ($this->_type == 'track') {
|
||||
$track = Track::find($this->_id);
|
||||
$track->comment_count = Comment::where('track_id', $this->_id)->count();
|
||||
$track->save();
|
||||
if ($this->_type === 'track') {
|
||||
$entity = Track::find($this->_id);
|
||||
|
||||
} elseif ($this->_type === 'album') {
|
||||
$entity = Album::find($this->_id);
|
||||
|
||||
} elseif ($this->_type === 'playlist') {
|
||||
$entity = Playlist::find($this->_id);
|
||||
|
||||
} elseif ($this->_type === 'user') {
|
||||
$entity = User::find($this->_id);
|
||||
|
||||
} else {
|
||||
App::abort(400, 'This comment is being added to an invalid entity!');
|
||||
}
|
||||
|
||||
$entity->comment_count = Comment::where($column, $this->_id)->count();
|
||||
$entity->save();
|
||||
|
||||
return CommandResponse::succeed(Comment::mapPublic($comment));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ class EditAlbumCommand extends CommandBase
|
|||
$this->_album->syncTrackIds($trackIds);
|
||||
$this->_album->save();
|
||||
|
||||
Album::whereId($this->_album->id)->update([
|
||||
Album::where('id', $this->_album->id)->update([
|
||||
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE album_id = ' . $this->_album->id . ')')
|
||||
]);
|
||||
|
||||
return CommandResponse::succeed(['real_cover_url' => $this->_album->getCoverUrl(Image::NORMAL)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use AlbumDownloader;
|
||||
use App\AlbumDownloader;
|
||||
use App;
|
||||
use App\Album;
|
||||
use App\ResourceLogItem;
|
||||
|
@ -67,4 +67,4 @@ class AlbumsController extends Controller
|
|||
$downloader = new AlbumDownloader($album, $formatName);
|
||||
$downloader->download();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use App\Playlist;
|
||||
use App\ResourceLogItem;
|
||||
use App\Track;
|
||||
use App\PlaylistDownloader;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use View;
|
||||
|
@ -67,4 +68,4 @@ class PlaylistsController extends Controller
|
|||
$downloader = new PlaylistDownloader($playlist, $formatName);
|
||||
$downloader->download();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use ZipStream;
|
||||
|
||||
class PlaylistDownloader
|
||||
{
|
||||
private $_playlist;
|
||||
|
@ -57,4 +61,4 @@ class PlaylistDownloader
|
|||
$zip->addFile($m3u, $playlistDir . $this->_playlist->title . '.m3u');
|
||||
$zip->finalize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue