mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-01-31 11: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\Cache;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use App\Traits\SlugTrait;
|
use App\Traits\SlugTrait;
|
||||||
|
use Helpers;
|
||||||
|
|
||||||
class Album extends Model
|
class Album extends Model
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use ZipStream;
|
||||||
|
|
||||||
class AlbumDownloader
|
class AlbumDownloader
|
||||||
{
|
{
|
||||||
private $_album;
|
private $_album;
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
|
|
||||||
namespace App\Commands;
|
namespace App\Commands;
|
||||||
|
|
||||||
|
use App\Album;
|
||||||
use App\Comment;
|
use App\Comment;
|
||||||
|
use App\Playlist;
|
||||||
use App\Track;
|
use App\Track;
|
||||||
|
use App\User;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
@ -76,12 +79,25 @@ class CreateCommentCommand extends CommandBase
|
||||||
$comment->save();
|
$comment->save();
|
||||||
|
|
||||||
// Recount the track's comments, if this is a track comment
|
// Recount the track's comments, if this is a track comment
|
||||||
if ($this->_type == 'track') {
|
if ($this->_type === 'track') {
|
||||||
$track = Track::find($this->_id);
|
$entity = Track::find($this->_id);
|
||||||
$track->comment_count = Comment::where('track_id', $this->_id)->count();
|
|
||||||
$track->save();
|
} 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));
|
return CommandResponse::succeed(Comment::mapPublic($comment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class EditAlbumCommand extends CommandBase
|
||||||
$this->_album->syncTrackIds($trackIds);
|
$this->_album->syncTrackIds($trackIds);
|
||||||
$this->_album->save();
|
$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 . ')')
|
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE album_id = ' . $this->_album->id . ')')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use AlbumDownloader;
|
use App\AlbumDownloader;
|
||||||
use App;
|
use App;
|
||||||
use App\Album;
|
use App\Album;
|
||||||
use App\ResourceLogItem;
|
use App\ResourceLogItem;
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
||||||
use App\Playlist;
|
use App\Playlist;
|
||||||
use App\ResourceLogItem;
|
use App\ResourceLogItem;
|
||||||
use App\Track;
|
use App\Track;
|
||||||
|
use App\PlaylistDownloader;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
use Illuminate\Support\Facades\Redirect;
|
||||||
use View;
|
use View;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use ZipStream;
|
||||||
|
|
||||||
class PlaylistDownloader
|
class PlaylistDownloader
|
||||||
{
|
{
|
||||||
private $_playlist;
|
private $_playlist;
|
||||||
|
|
Loading…
Reference in a new issue