Adopt Laravel coding style

Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions.

You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
This commit is contained in:
Laravel Shift 2021-02-14 02:39:15 +00:00
parent a1522f3cd7
commit 263ea48c5b
390 changed files with 43866 additions and 44115 deletions

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -59,20 +59,19 @@ class AddTrackToPlaylistCommand extends CommandBase
// check if this track is already in the playlist
$validator = Validator::make(
['track_id' => $this->_track->id],
['track_id' => "unique:playlist_track,track_id,null,id,playlist_id,{$this->_playlist->id}", ]
['track_id' => "unique:playlist_track,track_id,null,id,playlist_id,{$this->_playlist->id}"]
);
if ($validator->fails()) {
return CommandResponse::fail($validator);
}
$songIndex = $this->_playlist->trackCount() + 1;
$this->_playlist->tracks()->attach($this->_track, ['position' => $songIndex]);
$this->_playlist->touch();
Playlist::where('id', $this->_playlist->id)->update([
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$this->_playlist->id.')')
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$this->_playlist->id.')'),
]);
return CommandResponse::succeed(['message' => 'Track added!']);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -37,7 +37,7 @@ class CommandResponse
public static function fail($validatorOrMessages, int $statusCode = 400)
{
$response = new CommandResponse();
$response = new self();
$response->_didFail = true;
$response->_statusCode = $statusCode;
@ -53,7 +53,7 @@ class CommandResponse
public static function succeed($response = null, int $statusCode = 200)
{
$cmdResponse = new CommandResponse();
$cmdResponse = new self();
$cmdResponse->_didFail = false;
$cmdResponse->_response = $response;
$cmdResponse->_statusCode = $statusCode;

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,11 +20,11 @@
namespace App\Commands;
use Gate;
use App\Models\Album;
use App\Models\Image;
use Auth;
use App\Models\User;
use Auth;
use Gate;
use Validator;
class CreateAlbumCommand extends CommandBase
@ -60,7 +60,7 @@ class CreateAlbumCommand extends CommandBase
'cover' => 'image|mimes:png|min_width:350|min_height:350',
'cover_id' => 'exists:images,id',
'track_ids' => 'exists:tracks,id',
'user_id' => 'exists:users,id'
'user_id' => 'exists:users,id',
];
$validator = Validator::make($this->_input, $rules);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,8 @@
namespace App\Commands;
use Gate;
use App\Models\Announcement;
use Gate;
use Validator;
class CreateAnnouncementCommand extends CommandBase
@ -48,7 +48,6 @@ class CreateAnnouncementCommand extends CommandBase
*/
public function execute()
{
$rules = [
'name' => 'required|max:50',
];

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,13 +20,13 @@
namespace App\Commands;
use Notification;
use App\Models\Album;
use App\Models\Comment;
use App\Models\Playlist;
use App\Models\Track;
use App\Models\User;
use Auth;
use Notification;
use Validator;
class CreateCommentCommand extends CommandBase

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Commands;
use App\Models\Genre;
use Gate;
use Illuminate\Support\Str;
use App\Models\Genre;
use Validator;
class CreateGenreCommand extends CommandBase
@ -53,12 +53,12 @@ class CreateGenreCommand extends CommandBase
$rules = [
'name' => 'required|unique:genres,name,NULL,id,deleted_at,NULL|max:50',
'slug' => 'required|unique:genres,slug,NULL,id,deleted_at,NULL'
'slug' => 'required|unique:genres,slug,NULL,id,deleted_at,NULL',
];
$validator = Validator::make([
'name' => $this->_genreName,
'slug' => $slug
'slug' => $slug,
], $rules);
if ($validator->fails()) {
@ -67,7 +67,7 @@ class CreateGenreCommand extends CommandBase
Genre::create([
'name' => $this->_genreName,
'slug' => $slug
'slug' => $slug,
]);
return CommandResponse::succeed(['message' => 'Genre created!']);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Commands;
use Notification;
use App\Models\Playlist;
use Auth;
use Notification;
use Validator;
class CreatePlaylistCommand extends CommandBase
@ -53,7 +53,7 @@ class CreatePlaylistCommand extends CommandBase
$rules = [
'title' => 'required|min:3|max:50',
'is_public' => 'required',
'is_pinned' => 'required'
'is_pinned' => 'required',
];
$validator = Validator::make($this->_input, $rules);
@ -84,7 +84,7 @@ class CreatePlaylistCommand extends CommandBase
'description' => $playlist->description,
'url' => $playlist->url,
'is_pinned' => $this->_input['is_pinned'] == 'true',
'is_public' => $this->_input['is_public'] == 'true'
'is_public' => $this->_input['is_public'] == 'true',
]);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Commands;
use App\Models\ShowSong;
use Gate;
use Illuminate\Support\Str;
use App\Models\ShowSong;
use Validator;
class CreateShowSongCommand extends CommandBase
@ -53,12 +53,12 @@ class CreateShowSongCommand extends CommandBase
$rules = [
'title' => 'required|unique:show_songs,title,NULL,id,deleted_at,NULL|max:250',
'slug' => 'required|unique:show_songs,slug,NULL,id,deleted_at,NULL'
'slug' => 'required|unique:show_songs,slug,NULL,id,deleted_at,NULL',
];
$validator = Validator::make([
'title' => $this->_songName,
'slug' => $slug
'slug' => $slug,
], $rules);
if ($validator->fails()) {
@ -68,7 +68,7 @@ class CreateShowSongCommand extends CommandBase
ShowSong::create([
'title' => $this->_songName,
'slug' => $slug,
'lyrics' => ''
'lyrics' => '',
]);
return CommandResponse::succeed(['message' => 'Song created!']);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,8 @@
namespace App\Commands;
use Gate;
use App\Models\User;
use Gate;
use Validator;
class CreateUserCommand extends CommandBase
@ -72,7 +72,7 @@ class CreateUserCommand extends CommandBase
if ($validator->fails()) {
return CommandResponse::fail([
'message' => $validator->getMessageBag()->first(),
'user' => null
'user' => null,
]);
}
@ -81,12 +81,12 @@ class CreateUserCommand extends CommandBase
if ($user->wasRecentlyCreated) {
return CommandResponse::succeed([
'message' => 'New user successfully created!',
'user' => User::mapPublicUserSummary($user)
'user' => User::mapPublicUserSummary($user),
], 201);
} else {
return CommandResponse::fail([
'message' => 'A user with that username already exists.',
'user' => User::mapPublicUserSummary($user)
'user' => User::mapPublicUserSummary($user),
], 409);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Commands;
use Gate;
use App\Models\Album;
use Auth;
use Gate;
class DeleteAlbumCommand extends CommandBase
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,17 +20,16 @@
namespace App\Commands;
use App\Jobs\DeleteGenre;
use App\Models\Genre;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Models\Genre;
use App\Jobs\DeleteGenre;
use Validator;
class DeleteGenreCommand extends CommandBase
{
use DispatchesJobs;
/** @var Genre */
private $_genreToDelete;
private $_destinationGenre;
@ -67,7 +66,6 @@ class DeleteGenreCommand extends CommandBase
'destination_genre' => $this->_destinationGenre,
], $rules);
if ($validator->fails()) {
return CommandResponse::fail($validator);
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,17 +20,16 @@
namespace App\Commands;
use App\Jobs\DeleteShowSong;
use App\Models\ShowSong;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Models\ShowSong;
use App\Jobs\DeleteShowSong;
use Validator;
class DeleteShowSongCommand extends CommandBase
{
use DispatchesJobs;
/** @var ShowSong */
private $_songToDelete;
private $_destinationSong;
@ -67,7 +66,6 @@ class DeleteShowSongCommand extends CommandBase
'destination_song' => $this->_destinationSong,
], $rules);
if ($validator->fails()) {
return CommandResponse::fail($validator);
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,8 @@
namespace App\Commands;
use Gate;
use App\Models\Track;
use Gate;
class DeleteTrackCommand extends CommandBase
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -24,8 +24,8 @@ use App\Models\Album;
use App\Models\Image;
use App\Models\User;
use Auth;
use Gate;
use DB;
use Gate;
use Validator;
class EditAlbumCommand extends CommandBase
@ -63,7 +63,7 @@ class EditAlbumCommand extends CommandBase
'title' => 'required|min:3|max:50',
'cover' => 'image|mimes:png|min_width:350|min_height:350',
'cover_id' => 'exists:images,id',
'username' => 'exists:users,username'
'username' => 'exists:users,username',
];
$validator = Validator::make($this->_input, $rules);
@ -77,7 +77,7 @@ class EditAlbumCommand extends CommandBase
$trackDbCount = DB::table('tracks')->whereIn('id', $trackIds)->count();
if ($trackDbCount != $trackIdsCount) {
return CommandResponse::fail("Track IDs invalid");
return CommandResponse::fail('Track IDs invalid');
}
$this->_album->title = $this->_input['title'];

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -57,7 +57,7 @@ class EditPlaylistCommand extends CommandBase
$rules = [
'title' => 'required|min:3|max:50',
'is_public' => 'required',
'is_pinned' => 'required'
'is_pinned' => 'required',
];
$validator = Validator::make($this->_input, $rules);
@ -89,7 +89,7 @@ class EditPlaylistCommand extends CommandBase
'description' => $this->_playlist->description,
'url' => $this->_playlist->url,
'is_pinned' => $this->_input['is_pinned'] == 'true',
'is_public' => $this->_input['is_public'] == 'true'
'is_public' => $this->_input['is_public'] == 'true',
]);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,15 +20,15 @@
namespace App\Commands;
use Gate;
use Notification;
use App\Models\Album;
use App\Models\Image;
use App\Models\Playlist;
use App\Models\Track;
use App\Models\TrackType;
use App\Models\User;
use App\Models\Playlist;
use DB;
use Gate;
use Notification;
class EditTrackCommand extends CommandBase
{
@ -67,7 +67,7 @@ class EditTrackCommand extends CommandBase
'title' => 'required|min:3|max:80',
'released_at' => 'before:'.
(date('Y-m-d', time() + (86400 * 2))).(
isset($this->_input['released_at']) && $this->_input['released_at'] != ""
isset($this->_input['released_at']) && $this->_input['released_at'] != ''
? '|date'
: ''),
'license_id' => 'required|exists:licenses,id',
@ -76,7 +76,7 @@ class EditTrackCommand extends CommandBase
'track_type_id' => 'required|exists:track_types,id|not_in:'.TrackType::UNCLASSIFIED_TRACK,
'cover_id' => 'exists:images,id',
'album_id' => 'exists:albums,id',
'username' => 'exists:users,username'
'username' => 'exists:users,username',
];
if (isset($this->_input['track_type_id']) && $this->_input['track_type_id'] == TrackType::OFFICIAL_TRACK_REMIX) {
@ -92,7 +92,7 @@ class EditTrackCommand extends CommandBase
$track = $this->_track;
$track->title = $this->_input['title'];
$track->released_at = isset($this->_input['released_at']) && $this->_input['released_at'] != "" ? strtotime($this->_input['released_at']) : null;
$track->released_at = isset($this->_input['released_at']) && $this->_input['released_at'] != '' ? strtotime($this->_input['released_at']) : null;
$track->description = isset($this->_input['description']) ? $this->_input['description'] : '';
$track->lyrics = isset($this->_input['lyrics']) ? $this->_input['lyrics'] : '';
$track->license_id = $this->_input['license_id'];
@ -163,16 +163,16 @@ class EditTrackCommand extends CommandBase
$track->save();
User::whereId($this->_track->user_id)->update([
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = ' . $this->_track->user_id . ')')
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = '.$this->_track->user_id.')'),
]);
if ($oldid != null) {
User::whereId($oldid)->update([
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = ' . $oldid . ')')
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = '.$oldid.')'),
]);
}
if (isset($this->_input['hwc_submit']) && new \DateTime() < new \DateTime("2016-12-20 23:59:59")) {
if (isset($this->_input['hwc_submit']) && new \DateTime() < new \DateTime('2016-12-20 23:59:59')) {
$playlist = Playlist::where('user_id', 22549)->first();
if ($this->_input['hwc_submit'] == 'true') {
@ -182,7 +182,7 @@ class EditTrackCommand extends CommandBase
$playlist->touch();
Playlist::where('id', $playlist->id)->update([
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$playlist->id.')')
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$playlist->id.')'),
]);
}
} else {
@ -190,11 +190,12 @@ class EditTrackCommand extends CommandBase
$playlist->tracks()->detach($track);
Playlist::whereId($playlist->id)->update([
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$playlist->id.')')
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$playlist->id.')'),
]);
}
}
}
return CommandResponse::succeed(['real_cover_url' => $track->getCoverUrl(Image::NORMAL)]);
}
@ -215,7 +216,7 @@ class EditTrackCommand extends CommandBase
}
Album::whereId($album->id)->update([
'track_count' => DB::table('tracks')->where('album_id', '=', $album->id)->count()
'track_count' => DB::table('tracks')->where('album_id', '=', $album->id)->count(),
]);
}
@ -230,7 +231,7 @@ class EditTrackCommand extends CommandBase
$track->save();
$album->update([
'track_count' => DB::table('tracks')->where('album_id', '=', $album->id)->count()
'track_count' => DB::table('tracks')->where('album_id', '=', $album->id)->count(),
]);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,23 +20,21 @@
namespace App\Commands;
use App\Exceptions\InvalidEncodeOptionsException;
use App\Jobs\EncodeTrackFile;
use App\Models\Track;
use App\Models\TrackFile;
use AudioCache;
use FFmpegMovie;
use File;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Str;
use App\Exceptions\InvalidEncodeOptionsException;
use App\Jobs\EncodeTrackFile;
use App\Models\Track;
use App\Models\TrackFile;
use SplFileInfo;
/**
* This command is the "second phase" of the upload process - once metadata has
* been parsed and the track object is created, this generates the track's
* corresponding TrackFile objects and ensures that all of them have been encoded.
*
* @package App\Commands
*/
class GenerateTrackFilesCommand extends CommandBase
{
@ -53,7 +51,7 @@ class GenerateTrackFilesCommand extends CommandBase
'flac',
'pcm',
'adpcm',
'alac'
'alac',
];
public function __construct(Track $track, SplFileInfo $sourceFile, bool $autoPublish = false, bool $isForUpload = false, bool $isReplacingTrack = false, int $version = 1)
@ -90,6 +88,7 @@ class GenerateTrackFilesCommand extends CommandBase
$masterFormat = 'OGG Vorbis';
} else {
$this->track->delete();
return CommandResponse::fail(['track' => "The track does not contain audio in a known lossy format. The format read from the file is: {$codecString}"]);
}
@ -109,7 +108,6 @@ class GenerateTrackFilesCommand extends CommandBase
File::copy($source, $trackFile->getFile());
}
$trackFiles = [];
foreach (Track::$Formats as $name => $format) {
@ -161,6 +159,7 @@ class GenerateTrackFilesCommand extends CommandBase
} else {
$this->track->delete();
}
return CommandResponse::fail(['track' => [$e->getMessage()]]);
}
} catch (\Exception $e) {
@ -176,6 +175,7 @@ class GenerateTrackFilesCommand extends CommandBase
// This ensures that any updates to the track record, like from parsed
// tags, are reflected in the command's response.
$this->track = $this->track->fresh();
return CommandResponse::succeed([
'id' => $this->track->id,
'name' => $this->track->name,

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,6 @@
namespace App\Commands;
use Carbon\Carbon;
use DB;
use App\Models\Album;
use App\Models\Comment;
use App\Models\EmailSubscription;
@ -35,6 +33,8 @@ use App\Models\ResourceLogItem;
use App\Models\ResourceUser;
use App\Models\Track;
use App\Models\User;
use Carbon\Carbon;
use DB;
class MergeAccountsCommand extends CommandBase
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,18 +20,18 @@
namespace App\Commands;
use Carbon\Carbon;
use Config;
use getID3;
use App\Models\Album;
use App\Models\Genre;
use App\Models\Image;
use App\Models\Track;
use AudioCache;
use File;
use Illuminate\Support\Str;
use App\Models\TrackType;
use App\Models\User;
use AudioCache;
use Carbon\Carbon;
use Config;
use File;
use getID3;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@ -58,7 +58,6 @@ class ParseTrackTagsCommand extends CommandBase
list($parsedTags, $rawTags) = $this->parseOriginalTags($this->fileToParse, $this->track->user, $audio->getAudioCodec());
$this->track->original_tags = ['parsed_tags' => $parsedTags, 'raw_tags' => $rawTags];
if ($this->input['cover'] !== null) {
$this->track->cover_id = Image::upload($this->input['cover'], $this->track->user_id)->id;
} else {
@ -100,11 +99,12 @@ class ParseTrackTagsCommand extends CommandBase
$this->track = $this->unsetNullVariables($this->track);
$this->track->save();
return CommandResponse::succeed();
}
/**
* If a value is null, remove it! Helps prevent weird SQL errors
* If a value is null, remove it! Helps prevent weird SQL errors.
*
* @param Track
* @return Track
@ -138,7 +138,7 @@ class ParseTrackTagsCommand extends CommandBase
return Genre::create([
'name' => $genreName,
'slug' => Str::slug($genreName)
'slug' => Str::slug($genreName),
])->id;
} else {
// Exists in db, has it been deleted?
@ -150,6 +150,7 @@ class ParseTrackTagsCommand extends CommandBase
// instead of creating a new one
$existingGenre->restore();
return $existingGenre->id;
} else {
// It's fine, just return the ID
@ -166,7 +167,7 @@ class ParseTrackTagsCommand extends CommandBase
*
* @param int $artistId
* @param string|null $albumName
* @param integer|null $coverId
* @param int|null $coverId
* @return int|null
*/
protected function getAlbumId(int $artistId, $albumName, $coverId = null)
@ -174,7 +175,7 @@ class ParseTrackTagsCommand extends CommandBase
if (null !== $albumName) {
$album = Album::firstOrNew([
'user_id' => $artistId,
'title' => $albumName
'title' => $albumName,
]);
if (null === $album->id) {
@ -249,7 +250,6 @@ class ParseTrackTagsCommand extends CommandBase
//==========================================================================================================
$parsedTags['is_vocal'] = $parsedTags['lyrics'] !== null;
//==========================================================================================================
// Determine the genre.
//==========================================================================================================
@ -294,7 +294,6 @@ class ParseTrackTagsCommand extends CommandBase
$parsedTags['cover_id'] = $coverId;
//==========================================================================================================
// Is this part of an album?
//==========================================================================================================
@ -307,11 +306,9 @@ class ParseTrackTagsCommand extends CommandBase
$parsedTags['album_id'] = $albumId;
return [$parsedTags, $rawTags];
}
/**
* @param array $rawTags
* @return array
@ -326,7 +323,6 @@ class ParseTrackTagsCommand extends CommandBase
$tags = [];
}
$comment = null;
if (isset($tags['comment'])) {
@ -361,7 +357,7 @@ class ParseTrackTagsCommand extends CommandBase
'comments' => $comment,
'lyrics' => isset($tags['unsynchronised_lyric']) ? $tags['unsynchronised_lyric'][0] : null,
],
$tags
$tags,
];
}
@ -405,7 +401,7 @@ class ParseTrackTagsCommand extends CommandBase
'comments' => isset($tags['comments']) ? $tags['comments'][0] : null,
'lyrics' => isset($tags['lyrics']) ? $tags['lyrics'][0] : null,
],
$tags
$tags,
];
}
@ -441,7 +437,7 @@ class ParseTrackTagsCommand extends CommandBase
'comments' => isset($tags['comments']) ? $tags['comments'][0] : null,
'lyrics' => isset($tags['lyrics']) ? $tags['lyrics'][0] : null,
],
$tags
$tags,
];
}
@ -474,7 +470,7 @@ class ParseTrackTagsCommand extends CommandBase
// YYYY-MM
case 7:
try {
return Carbon::createFromFormat('Y m', str_replace("-", " ", $dateString))
return Carbon::createFromFormat('Y m', str_replace('-', ' ', $dateString))
->day(1);
} catch (\InvalidArgumentException $e) {
return null;
@ -483,7 +479,7 @@ class ParseTrackTagsCommand extends CommandBase
// YYYY-MM-DD
case 10:
try {
return Carbon::createFromFormat('Y m d', str_replace("-", " ", $dateString));
return Carbon::createFromFormat('Y m d', str_replace('-', ' ', $dateString));
} catch (\InvalidArgumentException $e) {
return null;
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -54,7 +54,7 @@ class RemoveTrackFromPlaylistCommand extends CommandBase
{
$this->_playlist->tracks()->detach($this->_track);
Playlist::whereId($this->_playlist->id)->update([
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$this->_playlist->id.')')
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = '.$this->_playlist->id.')'),
]);
return CommandResponse::succeed(['message' => 'Track removed!']);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,11 +20,11 @@
namespace App\Commands;
use App\Jobs\UpdateTagsForRenamedGenre;
use App\Models\Genre;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Str;
use App\Jobs\UpdateTagsForRenamedGenre;
use App\Models\Genre;
use Validator;
class RenameGenreCommand extends CommandBase
@ -59,15 +59,14 @@ class RenameGenreCommand extends CommandBase
$rules = [
'name' => 'required|unique:genres,name,'.$this->_genre->id.',id,deleted_at,NULL|max:50',
'slug' => 'required|unique:genres,slug,'.$this->_genre->id.',id,deleted_at,NULL'
'slug' => 'required|unique:genres,slug,'.$this->_genre->id.',id,deleted_at,NULL',
];
$validator = Validator::make([
'name' => $this->_newName,
'slug' => $slug
'slug' => $slug,
], $rules);
if ($validator->fails()) {
return CommandResponse::fail($validator);
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,11 +20,11 @@
namespace App\Commands;
use App\Jobs\UpdateTagsForRenamedShowSong;
use App\Models\ShowSong;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Str;
use App\Jobs\UpdateTagsForRenamedShowSong;
use App\Models\ShowSong;
use Validator;
class RenameShowSongCommand extends CommandBase
@ -59,15 +59,14 @@ class RenameShowSongCommand extends CommandBase
$rules = [
'title' => 'required|unique:show_songs,title,'.$this->_song->id.',id|max:250',
'slug' => 'required|unique:show_songs,slug,'.$this->_song->id.',id'
'slug' => 'required|unique:show_songs,slug,'.$this->_song->id.',id',
];
$validator = Validator::make([
'title' => $this->_newName,
'slug' => $slug
'slug' => $slug,
], $rules);
if ($validator->fails()) {
return CommandResponse::fail($validator);
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Commands;
use DB;
use App\Models\Image;
use App\Models\User;
use DB;
use Gate;
use Validator;
@ -63,7 +63,7 @@ class SaveAccountSettingsCommand extends CommandBase
'unique:users,slug,'.$this->_user->id,
'min:'.config('ponyfm.user_slug_minimum_length'),
'regex:/^[a-z\d-]+$/',
'is_not_reserved_slug'
'is_not_reserved_slug',
],
'notifications.*.activity_type' => 'required|exists:activity_types,activity_type',
'notifications.*.receive_emails' => 'present|boolean',
@ -77,14 +77,13 @@ class SaveAccountSettingsCommand extends CommandBase
}
$validator = Validator::make($this->_input, $rules, [
'slug.regex' => 'Slugs can only contain numbers, lowercase letters, and dashes.'
'slug.regex' => 'Slugs can only contain numbers, lowercase letters, and dashes.',
]);
if ($validator->fails()) {
return CommandResponse::fail($validator);
}
$this->_user->bio = $this->_input['bio'];
$this->_user->display_name = $this->_input['display_name'];
$this->_user->slug = $this->_input['slug'];
@ -112,13 +111,11 @@ class SaveAccountSettingsCommand extends CommandBase
// Sync email subscriptions
$emailSubscriptions = $this->_user->emailSubscriptions->keyBy('activity_type');
foreach ($this->_input['notifications'] as $notificationSetting) {
if (
$notificationSetting['receive_emails'] &&
! $emailSubscriptions->offsetExists($notificationSetting['activity_type'])
) {
$this->_user->emailSubscriptions()->create(['activity_type' => $notificationSetting['activity_type']]);
} elseif (
! $notificationSetting['receive_emails'] &&
$emailSubscriptions->offsetExists($notificationSetting['activity_type'])

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,15 +20,15 @@
namespace App\Commands;
use Notification;
use App\Contracts\Favouritable;
use App\Models\Favourite;
use App\Models\Track;
use App\Models\Album;
use App\Models\Favourite;
use App\Models\Playlist;
use App\Models\ResourceUser;
use App\Models\Track;
use Auth;
use DB;
use Notification;
class ToggleFavouriteCommand extends CommandBase
{
@ -98,14 +98,13 @@ class ToggleFavouriteCommand extends CommandBase
// for the same resource at the same time, the cached values will still be correct with this method.
DB::table($resourceTable)->whereId($this->_resourceId)->update([
'favourite_count' =>
DB::raw('(
'favourite_count' => DB::raw('(
SELECT
COUNT(id)
FROM
favourites
WHERE '.
$typeId.' = '.$this->_resourceId.')')
$typeId.' = '.$this->_resourceId.')'),
]);
return CommandResponse::succeed(['is_favourited' => $isFavourited]);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,14 +20,14 @@
namespace App\Commands;
use App\Models\Track;
use App\Models\User;
use Auth;
use Carbon\Carbon;
use Config;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;
use App\Models\Track;
use App\Models\User;
use Validator;
class UploadTrackCommand extends CommandBase
@ -115,6 +115,7 @@ class UploadTrackCommand extends CommandBase
$this->_track->version_upload_status = Track::STATUS_ERROR;
$this->_track->update();
}
return CommandResponse::fail(['track' => ['You must upload an audio file!']]);
}
@ -152,8 +153,7 @@ class UploadTrackCommand extends CommandBase
}
$rules = [
'track' =>
'required|'
'track' => 'required|'
.($this->_allowLossy
? 'audio_format:flac,alac,pcm,adpcm,aac,mp3,vorbis|'
: 'audio_format:flac,alac,pcm,adpcm|')
@ -176,7 +176,7 @@ class UploadTrackCommand extends CommandBase
'is_explicit' => 'boolean',
'is_downloadable' => 'boolean',
'is_listed' => 'boolean',
'metadata' => 'json'
'metadata' => 'json',
]);
}
$validator = \Validator::make($input, $rules);
@ -188,6 +188,7 @@ class UploadTrackCommand extends CommandBase
} else {
$this->_track->delete();
}
return CommandResponse::fail($validator);
}
@ -215,11 +216,13 @@ class UploadTrackCommand extends CommandBase
$this->_track->version_upload_status = Track::STATUS_ERROR;
$this->_track->update();
}
return $result;
}
}
$generateTrackFiles = new GenerateTrackFilesCommand($this->_track, $trackFile, $autoPublish, true, $this->_isReplacingTrack, $this->_version);
return $generateTrackFiles->execute();
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -40,7 +40,6 @@ class BootstrapLocalEnvironment extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -53,7 +53,6 @@ class ClassifyMLPMA extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -74,7 +73,7 @@ class ClassifyMLPMA extends Command
$this->comment('Importing tracks...');
$totalTracks = sizeof($tracks);
$totalTracks = count($tracks);
$fileToStartAt = (int) $this->option('startAt') - 1;
$this->comment("Skipping $fileToStartAt files...".PHP_EOL);
@ -88,7 +87,6 @@ class ClassifyMLPMA extends Command
$parsedTags = json_decode($track->parsed_tags, true);
//==========================================================================================================
// Original, show song remix, fan song remix, show audio remix, or ponified song?
//==========================================================================================================
@ -103,7 +101,6 @@ class ClassifyMLPMA extends Command
")
->get();
// If it has "Ingram" in the name, it's definitely an official song remix.
if (Str::contains(Str::lower($track->filename), 'ingram')) {
$this->info('This is an official song remix!');
@ -115,7 +112,6 @@ class ClassifyMLPMA extends Command
$parsedTags
);
// If it has "remix" in the name, it's definitely a remix.
} else {
if (Str::contains(Str::lower($sanitizedTrackTitle), 'remix')) {
@ -139,7 +135,6 @@ class ClassifyMLPMA extends Command
}
}
//==========================================================================================================
// Attach the data and publish the track!
//==========================================================================================================
@ -150,7 +145,7 @@ class ClassifyMLPMA extends Command
$track->published_at = $parsedTags['released_at'];
$track->save();
if (sizeof($linkedSongIds) > 0) {
if (count($linkedSongIds) > 0) {
$track->showSongs()->sync($linkedSongIds);
}
@ -167,24 +162,22 @@ class ClassifyMLPMA extends Command
* @param bool|false $isRemixOfOfficialTrack
* @return array
*/
protected function classifyTrack($filename, $officialSongs, $isRemixOfOfficialTrack = false, $tags)
protected function classifyTrack($filename, $officialSongs, $isRemixOfOfficialTrack, $tags)
{
$trackTypeId = null;
$linkedSongIds = [];
foreach ($officialSongs as $song) {
$this->comment('=> Matched official song: ['.$song->id.'] '.$song->title);
}
if ($isRemixOfOfficialTrack && sizeof($officialSongs) === 1) {
if ($isRemixOfOfficialTrack && count($officialSongs) === 1) {
$linkedSongIds = [$officialSongs[0]->id];
} else {
if ($isRemixOfOfficialTrack && sizeof($officialSongs) > 1) {
if ($isRemixOfOfficialTrack && count($officialSongs) > 1) {
$this->question('Multiple official songs matched! Please enter the ID of the correct one.');
} else {
if (sizeof($officialSongs) > 0) {
if (count($officialSongs) > 0) {
$this->question('This looks like a remix of an official song!');
$this->question('Press "r" if the match above is right!');
} else {

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Kelvin Zhang
* Copyright (C) 2015 Kelvin Zhang.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,10 @@
namespace App\Console\Commands;
use App\Models\TrackFile;
use Carbon\Carbon;
use File;
use Illuminate\Console\Command;
use App\Models\TrackFile;
class ClearTrackCache extends Command
{
@ -45,7 +45,6 @@ class ClearTrackCache extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,12 +20,12 @@
namespace App\Console\Commands;
use App\Models\Image;
use Config;
use DB;
use File;
use getID3;
use Illuminate\Console\Command;
use App\Models\Image;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class FixMLPMAImages extends Command
@ -47,7 +47,6 @@ class FixMLPMAImages extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -56,7 +55,6 @@ class FixMLPMAImages extends Command
protected $currentFile;
/**
* File extensions to ignore when importing the archive.
*
@ -69,7 +67,7 @@ class FixMLPMAImages extends Command
'txt',
'rtf',
'wma',
'wmv'
'wmv',
];
/**
@ -84,17 +82,16 @@ class FixMLPMAImages extends Command
$this->comment('Enumerating MLP Music Archive source files...');
$files = File::allFiles($mlpmaPath);
$this->info(sizeof($files).' files found!');
$this->info(count($files).' files found!');
$this->comment('Importing tracks...');
$totalFiles = sizeof($files);
$totalFiles = count($files);
$fileToStartAt = (int) $this->option('startAt') - 1;
$this->comment("Skipping $fileToStartAt files...".PHP_EOL);
$files = array_slice($files, $fileToStartAt);
$this->currentFile = $fileToStartAt;
foreach ($files as $file) {
$this->currentFile++;
@ -110,7 +107,6 @@ class FixMLPMAImages extends Command
->first();
$artistId = $importedTrack->user_id;
//==========================================================================================================
// Extract the original tags.
//==========================================================================================================
@ -119,7 +115,6 @@ class FixMLPMAImages extends Command
// all tags read by getID3, including the cover art
$allTags = $getId3->analyze($file->getPathname());
//==========================================================================================================
// Extract the cover art, if any exists.
//==========================================================================================================

View file

@ -2,21 +2,21 @@
namespace App\Console\Commands;
use App\Commands\UploadTrackCommand;
use App\Models\Album;
use App\Models\Genre;
use App\Models\Image;
use App\Models\Track;
use App\Models\User;
use Auth;
use Carbon\Carbon;
use Config;
use DB;
use File;
use Input;
use getID3;
use App\Models\Image;
use App\Models\Track;
use App\Models\User;
use App\Models\Genre;
use App\Models\Album;
use App\Commands\UploadTrackCommand;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use Input;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class ImportEQBeats extends Command
@ -94,7 +94,7 @@ class ImportEQBeats extends Command
$UNKNOWN_GENRE = Genre::firstOrCreate([
'name' => 'Unknown',
'slug' => 'unknown'
'slug' => 'unknown',
]);
//==========================================================================================================
@ -102,15 +102,15 @@ class ImportEQBeats extends Command
//==========================================================================================================
$this->comment('Enumerating files...');
$files = File::allFiles($archivePath);
$this->info(sizeof($files) . ' files found!');
$this->info(count($files).' files found!');
$this->comment('Enumerating artists...');
$artists = File::directories($archivePath);
$this->info(sizeof($artists) . ' artists found!');
$this->info(count($artists).' artists found!');
$this->comment('Importing tracks...');
$totalFiles = sizeof($files);
$totalFiles = count($files);
$fileToStartAt = (int) $this->option('startAt') - 1;
$this->comment("Skipping $fileToStartAt files...".PHP_EOL);
@ -183,11 +183,9 @@ class ImportEQBeats extends Command
if ($taggedYear !== null && $modifiedDate->year === $taggedYear) {
$releasedAt = $modifiedDate;
} elseif ($taggedYear !== null && $modifiedDate->year !== $taggedYear) {
$this->warn('Release years don\'t match! Using the tagged year...');
$releasedAt = Carbon::create($taggedYear);
} else {
// $taggedYear is null
$this->warn('This track isn\'t tagged with its release year! Using the track\'s last modified date...');
@ -215,7 +213,6 @@ class ImportEQBeats extends Command
$genre->restore();
}
$genreId = $genre->id;
} else {
$genre = new Genre();
$genre->name = $genreName;
@ -224,7 +221,6 @@ class ImportEQBeats extends Command
$genreId = $genre->id;
$this->comment('Created a new genre!');
}
} else {
$genreId = $UNKNOWN_GENRE->id; // "Unknown" genre ID
}
@ -236,7 +232,7 @@ class ImportEQBeats extends Command
$artist = User::where('display_name', '=', $artist_name)->first();
$artistId = null;
$this->comment("Checking for duplicates");
$this->comment('Checking for duplicates');
if ($artist) {
$artistId = $artist->id;
@ -254,7 +250,7 @@ class ImportEQBeats extends Command
$importFormat = $this->getFormat($file->getExtension());
if ($importFormat == null) {
// No idea what this is, skip file
$this->comment(sprintf("Not an audio file (%s), skipping...", $importFormat));
$this->comment(sprintf('Not an audio file (%s), skipping...', $importFormat));
continue;
}
@ -282,9 +278,8 @@ class ImportEQBeats extends Command
}
continue;
} else {
$this->comment("Found existing file");
$this->comment('Found existing file');
// Found a matching format, are they the same?
// Before we check it, see if it came from MLPMA
@ -307,8 +302,8 @@ class ImportEQBeats extends Command
$importHash = array_key_exists('md5_data_source', $sourceWithMd5) ? $sourceWithMd5['md5_data_source'] : $sourceWithMd5['md5_data'];
$targetHash = array_key_exists('md5_data_source', $existingFileTags) ? $existingFileTags['md5_data_source'] : $existingFileTags['md5_data'];
$this->info("Archive hash: " . $importHash);
$this->info("Pony.fm hash: " . $targetHash);
$this->info('Archive hash: '.$importHash);
$this->info('Pony.fm hash: '.$targetHash);
if ($importHash == $targetHash) {
// Audio is identical, no need to reupload
@ -319,16 +314,18 @@ class ImportEQBeats extends Command
if (strlen($existingTrack->description) < strlen($parsedTags['comments'])) {
$existingTrack->description = $parsedTags['comments'];
$changedMetadata = true;
$this->comment("Updated description");
$this->comment('Updated description');
}
if (strlen($existingTrack->lyrics) < strlen($parsedTags['lyrics'])) {
$existingTrack->lyrics = $parsedTags['lyrics'];
$changedMetadata = true;
$this->comment("Updated lyrics");
$this->comment('Updated lyrics');
}
if ($changedMetadata) $existingTrack->save();
if ($changedMetadata) {
$existingTrack->save();
}
continue;
} else {
@ -340,7 +337,7 @@ class ImportEQBeats extends Command
continue;
}
} else {
$this->comment("Not replacing, user uploaded");
$this->comment('Not replacing, user uploaded');
// We can update the metadata though
$changedMetadata = false;
@ -348,21 +345,23 @@ class ImportEQBeats extends Command
if (strlen($existingTrack->description) < strlen($parsedTags['comments'])) {
$existingTrack->description = $parsedTags['comments'];
$changedMetadata = true;
$this->comment("Updated description");
$this->comment('Updated description');
}
if (strlen($existingTrack->lyrics) < strlen($parsedTags['lyrics'])) {
$existingTrack->lyrics = $parsedTags['lyrics'];
$changedMetadata = true;
$this->comment("Updated lyrics");
$this->comment('Updated lyrics');
}
if ($changedMetadata) $existingTrack->save();
if ($changedMetadata) {
$existingTrack->save();
}
continue;
}
}
} else {
$this->comment("No duplicates");
$this->comment('No duplicates');
}
//==========================================================================================================
@ -443,7 +442,7 @@ class ImportEQBeats extends Command
$album->title = $albumName;
$album->user_id = $artist->id;
$album->cover_id = $coverId;
$album->description = "";
$album->description = '';
$album->save();
}
@ -479,8 +478,8 @@ class ImportEQBeats extends Command
$track->is_downloadable = true;
$track->is_vocal = $isVocal;
$track->license_id = 2;
$track->description = "";
$track->lyrics = "";
$track->description = '';
$track->lyrics = '';
if (! is_null($parsedTags['comments'])) {
$track->description = $parsedTags['comments'];
@ -501,7 +500,7 @@ class ImportEQBeats extends Command
->insert([
'track_id' => $result->getResponse()['id'],
'path' => $file->getRelativePath(),
'filename' => iconv("UTF-8", "ISO-8859-1//TRANSLIT", $file->getFilename()),
'filename' => iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $file->getFilename()),
'extension' => $file->getExtension(),
'imported_at' => Carbon::now(),
'parsed_tags' => json_encode($parsedTags),
@ -513,13 +512,16 @@ class ImportEQBeats extends Command
}
}
protected function hashAudio($filepath) {
protected function hashAudio($filepath)
{
$hash = hash_file('crc32b', $filepath);
$array = unpack('N', pack('H*', $hash));
return $array[1];
}
protected function getFormat($extension) {
protected function getFormat($extension)
{
foreach (Track::$Formats as $name => $format) {
if ($format['extension'] == $extension) {
return $name;
@ -565,7 +567,6 @@ class ImportEQBeats extends Command
$rawTags = [];
}
return [$parsedTags, $rawTags];
}
@ -623,7 +624,7 @@ class ImportEQBeats extends Command
'comments' => $comment,
'lyrics' => isset($tags['unsynchronised_lyric']) ? $tags['unsynchronised_lyric'][0] : null,
],
$tags
$tags,
];
}
@ -667,7 +668,7 @@ class ImportEQBeats extends Command
'comments' => isset($tags['comments']) ? $tags['comments'][0] : null,
'lyrics' => isset($tags['lyrics']) ? $tags['lyrics'][0] : null,
],
$tags
$tags,
];
}
@ -703,7 +704,7 @@ class ImportEQBeats extends Command
'comments' => isset($tags['comments']) ? $tags['comments'][0] : null,
'lyrics' => isset($tags['lyrics']) ? $tags['lyrics'][0] : null,
],
$tags
$tags,
];
}
@ -736,7 +737,7 @@ class ImportEQBeats extends Command
// YYYY-MM
case 7:
try {
return Carbon::createFromFormat('Y m', str_replace("-", " ", $dateString))
return Carbon::createFromFormat('Y m', str_replace('-', ' ', $dateString))
->day(1);
} catch (\InvalidArgumentException $e) {
return null;
@ -745,7 +746,7 @@ class ImportEQBeats extends Command
// YYYY-MM-DD
case 10:
try {
return Carbon::createFromFormat('Y m d', str_replace("-", " ", $dateString));
return Carbon::createFromFormat('Y m d', str_replace('-', ' ', $dateString));
} catch (\InvalidArgumentException $e) {
return null;
}
@ -762,7 +763,8 @@ class ImportEQBeats extends Command
}
}
protected function replaceTrack($toBeUploaded, $targetTrack, $artist, $mime) {
protected function replaceTrack($toBeUploaded, $targetTrack, $artist, $mime)
{
Auth::loginUsingId($artist->id);
$trackFile = new UploadedFile($toBeUploaded->getPathname(), $toBeUploaded->getFilename(), $mime, null, null, true);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,6 @@
namespace App\Console\Commands;
use Carbon\Carbon;
use DB;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use App\Commands\MergeAccountsCommand;
use App\Models\Album;
use App\Models\Comment;
@ -36,6 +32,10 @@ use App\Models\ResourceLogItem;
use App\Models\ResourceUser;
use App\Models\Track;
use App\Models\User;
use Carbon\Carbon;
use DB;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
class MergeAccounts extends Command
{
@ -57,7 +57,6 @@ class MergeAccounts extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -81,9 +80,10 @@ class MergeAccounts extends Command
if (null !== $sourceAccount->getAccessToken()) {
$this->warn("WARNING: The source account (ID {$sourceAccountId}) is linked to a Poniverse account! Normally, the destination account should be the one that's linked to a Poniverse account as that's the one that the artist will be logging into.");
$this->line('');
$this->warn("If you continue with this merge, the Poniverse account linked to the source Pony.fm account will no longer be able to log into Pony.fm.");
$this->warn('If you continue with this merge, the Poniverse account linked to the source Pony.fm account will no longer be able to log into Pony.fm.');
if (! $this->confirm('Continue merging this set of source and destination accounts?')) {
$this->error('Merge aborted.');
return 1;
}
}
@ -93,6 +93,7 @@ class MergeAccounts extends Command
$this->warn("This is normal if you're merging two archived profiles but not if you're helping an artist claim their profile.");
if (! $this->confirm('Continue merging this set of source and destination accounts?')) {
$this->error('Merge aborted.');
return 1;
}
}
@ -101,6 +102,7 @@ class MergeAccounts extends Command
$command = new MergeAccountsCommand($sourceAccount, $destinationAccount);
$command->execute();
return 0;
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -45,7 +45,6 @@ class MigrateOldData extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -94,7 +93,7 @@ class MigrateOldData extends Command
'username' => $user->username,
'uses_gravatar' => $user->uses_gravatar,
'gravatar' => $user->gravatar,
'avatar_id' => null
'avatar_id' => null,
]);
$coverId = null;
@ -119,7 +118,7 @@ class MigrateOldData extends Command
DB::table('genres')->insert([
'id' => $genre->id,
'name' => $genre->title,
'slug' => $genre->slug
'slug' => $genre->slug,
]);
}
@ -139,7 +138,7 @@ class MigrateOldData extends Command
'id' => $playlist->id,
'user_id' => $playlist->user_id,
'view_count' => 0,
'download_count' => 0
'download_count' => 0,
]);
foreach ($logViews as $logItem) {
@ -164,7 +163,7 @@ class MigrateOldData extends Command
'album_id' => $logItem->album_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
'track_format_id' => $logItem->track_file_format_id - 1
'track_format_id' => $logItem->track_file_format_id - 1,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for album '.$playlist->id.' because '.$e->getMessage());
@ -219,7 +218,7 @@ class MigrateOldData extends Command
'duration' => $track->duration,
'view_count' => 0,
'play_count' => 0,
'download_count' => 0
'download_count' => 0,
]);
foreach ($trackLogViews as $logItem) {
@ -229,7 +228,7 @@ class MigrateOldData extends Command
'log_type' => ResourceLogItem::VIEW,
'track_id' => $logItem->track_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address
'ip_address' => $logItem->ip_address,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for track '.$track->id.' because '.$e->getMessage());
@ -243,7 +242,7 @@ class MigrateOldData extends Command
'log_type' => ResourceLogItem::PLAY,
'track_id' => $logItem->track_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address
'ip_address' => $logItem->ip_address,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for track '.$track->id.' because '.$e->getMessage());
@ -258,7 +257,7 @@ class MigrateOldData extends Command
'track_id' => $logItem->track_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
'track_format_id' => $logItem->track_file_format_id - 1
'track_format_id' => $logItem->track_file_format_id - 1,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for track '.$track->id.' because '.$e->getMessage());
@ -272,7 +271,7 @@ class MigrateOldData extends Command
DB::table('show_song_track')->insert([
'id' => $song->id,
'show_song_id' => $song->song_id,
'track_id' => $song->track_id
'track_id' => $song->track_id,
]);
} catch (\Exception $e) {
$this->error('Could insert show track item for '.$song->track_id.' because '.$e->getMessage());
@ -321,7 +320,7 @@ class MigrateOldData extends Command
'playlist_id' => $logItem->playlist_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
'track_format_id' => $logItem->track_file_format_id - 1
'track_format_id' => $logItem->track_file_format_id - 1,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for playlist '.$playlist->id.' because '.$e->getMessage());
@ -338,7 +337,7 @@ class MigrateOldData extends Command
'updated_at' => $playlistTrack->updated_at,
'position' => $playlistTrack->position,
'playlist_id' => $playlistTrack->playlist_id,
'track_id' => $playlistTrack->track_id
'track_id' => $playlistTrack->track_id,
]);
}
@ -356,7 +355,7 @@ class MigrateOldData extends Command
'track_id' => $comment->track_id,
'album_id' => $comment->album_id,
'playlist_id' => $comment->playlist_id,
'profile_id' => $comment->profile_id
'profile_id' => $comment->profile_id,
]);
} catch (Exception $e) {
$this->error('Could not sync comment '.$comment->id.' because '.$e->getMessage());

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Console\Commands;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Console\Command;
use GuzzleHttp\Client;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
class PoniverseApiSetup extends Command
@ -43,7 +43,6 @@ class PoniverseApiSetup extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -74,7 +73,7 @@ class PoniverseApiSetup extends Command
$response = $client->post('api-credentials', [
'headers' => ['accept' => 'application/json'],
'auth' => [$username, $password],
'query' => ['app' => 'Pony.fm']
'query' => ['app' => 'Pony.fm'],
]);
} catch (ClientException $e) {
if ($e->getResponse()->getStatusCode() === 401) {
@ -97,7 +96,6 @@ class PoniverseApiSetup extends Command
$this->info('Client ID and secret set!');
}
protected function setEnvironmentVariable($key, $oldValue, $newValue)
{
$path = base_path('.env');

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,8 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Console\Command;
class RebuildArtists extends Command
{
@ -41,7 +41,6 @@ class RebuildArtists extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Kelvin Zhang
* Copyright (C) 2015 Kelvin Zhang.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Console\Commands;
use App\Models\TrackFile;
use File;
use Illuminate\Console\Command;
use App\Models\TrackFile;
class RebuildFilesizes extends Command
{
@ -43,7 +43,6 @@ class RebuildFilesizes extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -65,12 +64,10 @@ class RebuildFilesizes extends Command
)
) {
TrackFile::chunk(200, function ($trackFiles) {
$this->info('========== Start Chunk ==========');
foreach ($trackFiles as $trackFile) {
/** @var TrackFile $trackFile */
if (File::exists($trackFile->getFile())) {
$size = $trackFile->updateFilesize();
$this->info('ID '.$trackFile->id.' processed - '.$size.' bytes');

View file

@ -1,7 +1,7 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2017 Isaac Avram
* Copyright (C) 2017 Isaac Avram.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -19,8 +19,8 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Image;
use Illuminate\Console\Command;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
use Symfony\Component\HttpFoundation\File\File;
@ -57,7 +57,7 @@ class RebuildImages extends Command
*/
public function handle()
{
$this->info("Regenerating Images");
$this->info('Regenerating Images');
$progressBar = $this->output->createProgressBar(Image::count());
Image::chunk(1000, function ($images) use ($progressBar) {

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,12 +20,12 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;
use App\Models\Album;
use App\Models\Playlist;
use App\Models\Track;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;
class RebuildSearchIndex extends Command
{
@ -45,7 +45,6 @@ class RebuildSearchIndex extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -65,7 +64,7 @@ class RebuildSearchIndex extends Command
$totalUsers = User::count();
$trackProgress = $this->output->createProgressBar($totalTracks);
$this->info("Processing tracks...");
$this->info('Processing tracks...');
Track::withTrashed()->chunk(200, function (Collection $tracks) use ($trackProgress) {
foreach ($tracks as $track) {
/** @var Track $track */
@ -76,9 +75,8 @@ class RebuildSearchIndex extends Command
$trackProgress->finish();
$this->line('');
$albumProgress = $this->output->createProgressBar($totalAlbums);
$this->info("Processing albums...");
$this->info('Processing albums...');
Album::withTrashed()->chunk(200, function (Collection $albums) use ($albumProgress) {
foreach ($albums as $album) {
/** @var Album $album */
@ -89,9 +87,8 @@ class RebuildSearchIndex extends Command
$albumProgress->finish();
$this->line('');
$playlistProgress = $this->output->createProgressBar($totalPlaylists);
$this->info("Processing playlists...");
$this->info('Processing playlists...');
Playlist::withTrashed()->chunk(200, function (Collection $playlists) use ($playlistProgress) {
foreach ($playlists as $playlist) {
/** @var Playlist $playlist */
@ -102,9 +99,8 @@ class RebuildSearchIndex extends Command
$playlistProgress->finish();
$this->line('');
$userProgress = $this->output->createProgressBar($totalUsers);
$this->info("Processing users...");
$this->info('Processing users...');
User::chunk(200, function (Collection $users) use ($userProgress) {
foreach ($users as $user) {
/** @var User $user */

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -42,7 +42,6 @@ class RebuildTags extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -63,7 +62,7 @@ class RebuildTags extends Command
$tracks = Track::whereNotNull('published_at')->withTrashed()->orderBy('id', 'asc')->get();
}
$numberOfTracks = sizeof($tracks);
$numberOfTracks = count($tracks);
$this->info("Updating tags for ${numberOfTracks} tracks...");
$bar = $this->output->createProgressBar($numberOfTracks);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,11 +20,11 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Commands\GenerateTrackFilesCommand;
use App\Jobs\EncodeTrackFile;
use App\Models\Track;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
class RebuildTrack extends Command
{
@ -48,7 +48,6 @@ class RebuildTrack extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -78,7 +77,7 @@ class RebuildTrack extends Command
// The GenerateTrackFiles command will re-encode all TrackFiles.
if ($result->didFail()) {
$this->error("Something went wrong!");
$this->error('Something went wrong!');
print_r($result->getMessages());
}
} else {
@ -95,7 +94,7 @@ class RebuildTrack extends Command
private function printTrackInfo(Track $track)
{
$this->comment("Track info:");
$this->comment('Track info:');
$this->comment(" Title: {$track->title}");
$this->comment(" Uploaded at: {$track->created_at}");
$this->comment(" Artist: {$track->user->display_name} [User ID: {$track->user_id}]");

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Kelvin Zhang
* Copyright (C) 2015 Kelvin Zhang.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,16 +20,15 @@
namespace App\Console\Commands;
use File;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Jobs\EncodeTrackFile;
use App\Models\Track;
use App\Models\TrackFile;
use File;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
class RebuildTrackCache extends Command
{
use DispatchesJobs;
/**
@ -49,7 +48,6 @@ class RebuildTrackCache extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -172,7 +170,6 @@ class RebuildTrackCache extends Command
$this->output->newLine(1);
});
$this->info('Format(s) set from cacheable to non-cacheable: '.implode(' ', array_unique($formats)));
$this->info($trackFileCount.' cacheable track files set to non-cacheable.');
@ -209,7 +206,6 @@ class RebuildTrackCache extends Command
$this->output->newLine(1);
});
$this->info(sprintf('%d track files deleted out of %d track files. Continuing.', $count, $trackFileCount));
//==========================================================================================================
@ -248,7 +244,6 @@ class RebuildTrackCache extends Command
$this->output->newLine(1);
});
$this->info($count.' track files encoded.');
$this->output->newLine(1);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -42,7 +42,6 @@ class RefreshCache extends Command
/**
* Create a new command instance.
*
*/
public function __construct()
{
@ -62,17 +61,17 @@ class RefreshCache extends Command
DB::table('albums')->update([
'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.album_id = albums.id AND deleted_at IS NULL)'),
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE album_id = albums.id)')
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE album_id = albums.id)'),
]);
DB::table('playlists')->update([
'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.playlist_id = playlists.id AND deleted_at IS NULL)'),
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = playlists.id)')
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = playlists.id)'),
]);
DB::table('users')->update([
'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.profile_id = users.id AND deleted_at IS NULL)'),
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = users.id)')
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = users.id)'),
]);
$users = DB::table('users')->get();
@ -80,7 +79,7 @@ class RefreshCache extends Command
$resources = [
'album' => [],
'playlist' => [],
'track' => []
'track' => [],
];
foreach ($users as $user) {
@ -235,7 +234,7 @@ class RefreshCache extends Command
'view_count' => 0,
'play_count' => 0,
'download_count' => 0,
'user_id' => $userId
'user_id' => $userId,
];
$item[$type.'_id'] = $id;

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,10 @@
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use League\OAuth2\Client\Token\AccessToken;
use Poniverse\Lib\Client;
use App\Models\User;
class SyncPoniverseAccounts extends Command
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Kelvin Zhang
* Copyright (C) 2016 Kelvin Zhang.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Console\Commands;
use App\Models\TrackFile;
use File;
use Illuminate\Console\Command;
use App\Models\TrackFile;
class VersionFiles extends Command
{
@ -62,7 +62,6 @@ class VersionFiles extends Command
if ($this->option('force') || $this->confirm('Are you sure you want to rename all unversioned track files? [y|N]', false)) {
TrackFile::chunk(200, function ($trackFiles) {
$this->info('========== Start Chunk ==========');
foreach ($trackFiles as $trackFile) {

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -25,8 +25,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* This interface is used for type safety when referring to entities that
* are capable of accepting comments.
*
* @package App\Contracts
*/
interface Commentable extends GeneratesNotifications
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -25,8 +25,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* This interface is used for type safety when referring to entities that
* are capable of being favourited.
*
* @package App\Contracts
*/
interface Favouritable extends GeneratesNotifications
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,14 +20,12 @@
namespace App\Contracts;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use App\Models\User;
use Illuminate\Database\Eloquent\Relations\MorphMany;
/**
* This interface is used for type safety when referring to entities that can be
* the "target resource" of a notification (ie. what the notification is about).
*
* @package App\Contracts
*/
interface GeneratesNotifications
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -26,12 +26,7 @@ use App\Models\Track;
use App\Models\User;
/**
* Interface NotificationHandler
* @package App\Contracts
*
* Each method in this interface represents a type of notification. To add a new
* type of notification, add a method for it to this interface and every class
* that implements it. Your IDE should be able to help with this.
* Interface NotificationHandler.
*/
interface NotificationHandler
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -36,5 +36,6 @@ interface Searchable
public function shouldBeIndexed():bool;
public function updateElasticsearchEntry();
public function updateElasticsearchEntrySynchronously();
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -21,8 +21,8 @@
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use GrahamCampbell\Exceptions\ExceptionHandler;
use Illuminate\Auth\AuthenticationException;
class Handler extends ExceptionHandler
{
@ -45,7 +45,6 @@ class Handler extends ExceptionHandler
'password_confirmation',
];
/**
* Report or log an exception.
*

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -23,7 +23,7 @@ namespace App\Exceptions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
/**
* Class TrackFileNotFoundException
* Class TrackFileNotFoundException.
*
* This exception is used to indicate that the requested `TrackFile` object
* does not exist. This is useful when dealing with albums or playlists that

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,8 @@
namespace App\Http\Controllers;
use App\AlbumDownloader;
use App;
use App\AlbumDownloader;
use App\Models\Album;
use App\Models\ResourceLogItem;
use App\Models\Track;

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -41,7 +41,7 @@ class TracksController extends Controller
$json = [
'total_tracks' => $tracks->count(),
'tracks' => $tracks->toArray()
'tracks' => $tracks->toArray(),
];
return Response::json($json, 200);
@ -53,7 +53,7 @@ class TracksController extends Controller
$json = [
'total_tracks' => $tracks->count(),
'tracks' => $tracks->toArray()
'tracks' => $tracks->toArray(),
];
return Response::json($json, 200);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0
* Copyright (C) 2015-2017 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -44,16 +44,16 @@ class TracksController extends ApiControllerBase
'status_url' => action('Api\V1\TracksController@getUploadStatus', ['id' => $commandData['id']]),
'track_url' => action('TracksController@getTrack', ['id' => $commandData['id'], 'slug' => $commandData['slug']]),
'message' => $commandData['autoPublish']
? "This track has been accepted for processing! Poll the status_url to know when it has been published. It will be published at the track_url."
? 'This track has been accepted for processing! Poll the status_url to know when it has been published. It will be published at the track_url.'
: "This track has been accepted for processing! Poll the status_url to know when it's ready to publish. It will be published at the track_url.",
];
$response->setData($data);
$response->setStatusCode(202);
return $response;
}
public function getUploadStatus($trackId)
{
$track = Track::findOrFail($trackId);
@ -67,7 +67,7 @@ class TracksController extends ApiControllerBase
? 'Processing complete! The track is live at the track_url. The artist can edit the track by visiting its edit_url.'
: 'Processing complete! The artist must publish the track by visiting its edit_url.',
'edit_url' => action('ContentController@getTracks', ['id' => $trackId]),
'track_url' => $track->url
'track_url' => $track->url,
], 201);
} else {
// something went wrong
@ -83,7 +83,8 @@ class TracksController extends ApiControllerBase
* @param int $id track ID
* @return \Illuminate\Http\JsonResponse
*/
public function getTrackDetails($id) {
public function getTrackDetails($id)
{
/** @var Track|null $track */
$track = Track
::with('user', 'album', 'user.avatar', 'cover', 'genre')
@ -126,7 +127,8 @@ class TracksController extends ApiControllerBase
* @param bool $includeComments if true, includes the track's comments in the serialization
* @return array serialized track
*/
private static function trackToJson(Track $track, bool $includeComments, bool $includeStreamUrl) {
private static function trackToJson(Track $track, bool $includeComments, bool $includeStreamUrl)
{
$trackResponse = [
'id' => $track->id,
'title' => $track->title,
@ -139,41 +141,41 @@ class TracksController extends ApiControllerBase
'avatars' => [
'thumbnail' => $track->user->getAvatarUrl(Image::THUMBNAIL),
'small' => $track->user->getAvatarUrl(Image::SMALL),
'normal' => $track->user->getAvatarUrl(Image::NORMAL)
]
'normal' => $track->user->getAvatarUrl(Image::NORMAL),
],
],
'stats' => [
'views' => $track->view_count,
'plays' => $track->play_count,
'downloads' => $track->download_count,
'comments' => $track->comment_count,
'favourites' => $track->favourite_count
'favourites' => $track->favourite_count,
],
'url' => $track->url,
'is_vocal' => !!$track->is_vocal,
'is_explicit' => !!$track->is_explicit,
'is_downloadable' => !!$track->is_downloadable,
'is_vocal' => (bool) $track->is_vocal,
'is_explicit' => (bool) $track->is_explicit,
'is_downloadable' => (bool) $track->is_downloadable,
'published_at' => $track->published_at,
'duration' => $track->duration,
'genre' => $track->genre != null
?
[
'id' => $track->genre->id,
'name' => $track->genre->name
'name' => $track->genre->name,
] : null,
'type' => [
'id' => $track->trackType->id,
'name' => $track->trackType->title
'name' => $track->trackType->title,
],
'covers' => [
'thumbnail' => $track->getCoverUrl(Image::THUMBNAIL),
'small' => $track->getCoverUrl(Image::SMALL),
'normal' => $track->getCoverUrl(Image::NORMAL)
'normal' => $track->getCoverUrl(Image::NORMAL),
],
// As of 2017-10-28, this should be expected to produce
// "direct_upload", "mlpma", "ponify", or "eqbeats" for all tracks.
'source' => $track->source
'source' => $track->source,
];
if ($includeComments) {
@ -191,8 +193,8 @@ class TracksController extends ApiControllerBase
'normal' => $comment->user->getAvatarUrl(Image::NORMAL),
'thumbnail' => $comment->user->getAvatarUrl(Image::THUMBNAIL),
'small' => $comment->user->getAvatarUrl(Image::SMALL),
]
]
],
],
];
}
@ -204,7 +206,7 @@ class TracksController extends ApiControllerBase
'mp3' => [
'url' => $track->getStreamUrl('MP3', session('api_client_id')),
'mime_type' => Track::$Formats['MP3']['mime_type'],
]
],
];
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,12 +20,12 @@
namespace App\Http\Controllers\Api\Web;
use App\Http\Controllers\ApiControllerBase;
use App\Commands\SaveAccountSettingsCommand;
use App\Models\User;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Image;
use Gate;
use App\Models\User;
use Auth;
use Gate;
use Request;
use Response;
@ -36,11 +36,12 @@ class AccountController extends ApiControllerBase
$this->authorize('edit', $user);
return Response::json([
'user' => $user->toArray()
'user' => $user->toArray(),
]);
}
public function getCurrentUser() {
public function getCurrentUser()
{
$current_user = Auth::user();
if ($current_user != null) {
@ -58,9 +59,9 @@ class AccountController extends ApiControllerBase
'is_archived' => $user->is_archived,
'avatars' => [
'small' => $user->getAvatarUrl(Image::SMALL),
'normal' => $user->getAvatarUrl(Image::NORMAL)
'normal' => $user->getAvatarUrl(Image::NORMAL),
],
'created_at' => $user->created_at
'created_at' => $user->created_at,
], 200);
} else {
return Response::json(['error' => 'You are not logged in'], 404);
@ -88,7 +89,6 @@ class AccountController extends ApiControllerBase
}
}
return Response::json([
'id' => $user->id,
'bio' => $user->bio,
@ -100,7 +100,7 @@ class AccountController extends ApiControllerBase
'avatar_url' => ! $user->uses_gravatar ? $user->getAvatarUrl() : null,
'uses_gravatar' => $user->uses_gravatar == 1,
'notification_email' => $user->email,
'notifications' => $user->getNotificationSettings()
'notifications' => $user->getNotificationSettings(),
], 200);
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,20 +20,20 @@
namespace App\Http\Controllers\Api\Web;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Models\Album;
use App\Commands\CreateAlbumCommand;
use App\Commands\DeleteAlbumCommand;
use App\Commands\EditAlbumCommand;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Album;
use App\Models\Image;
use App\Models\ResourceLogItem;
use App\Models\Track;
use App\Models\User;
use Auth;
use Gate;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request;
use App\Models\User;
use Response;
use App\Models\Track;
class AlbumsController extends ApiControllerBase
{
@ -66,7 +66,7 @@ class AlbumsController extends ApiControllerBase
'user',
'user.avatar',
'comments',
'comments.user'
'comments.user',
])
->userDetails()
->find($id);
@ -86,7 +86,7 @@ class AlbumsController extends ApiControllerBase
}
return Response::json([
'album' => $returned_album
'album' => $returned_album,
], 200);
}
@ -144,7 +144,7 @@ class AlbumsController extends ApiControllerBase
}
return Response::json(
["albums" => $albums, "current_page" => $page, "total_pages" => ceil($count / $perPage)],
['albums' => $albums, 'current_page' => $page, 'total_pages' => ceil($count / $perPage)],
200
);
}
@ -167,8 +167,8 @@ class AlbumsController extends ApiControllerBase
'created_at' => $album->created_at->format('c'),
'covers' => [
'small' => $album->getCoverUrl(Image::SMALL),
'normal' => $album->getCoverUrl(Image::NORMAL)
]
'normal' => $album->getCoverUrl(Image::NORMAL),
],
];
}
@ -190,7 +190,7 @@ class AlbumsController extends ApiControllerBase
foreach ($album->tracks as $track) {
$tracks[] = [
'id' => $track->id,
'title' => $track->title
'title' => $track->title,
];
}
@ -205,7 +205,7 @@ class AlbumsController extends ApiControllerBase
'description' => $album->description,
'cover_url' => $album->hasCover() ? $album->getCoverUrl(Image::NORMAL) : null,
'real_cover_url' => $album->getCoverUrl(Image::NORMAL),
'tracks' => $tracks
'tracks' => $tracks,
], 200);
}
}

View file

@ -2,12 +2,12 @@
namespace App\Http\Controllers\Api\Web;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Session\Store;
use App\Http\Controllers\Controller;
use App\Models\AlexaSession;
use App\Models\Track;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Session\Store;
use Psr\Log\LoggerInterface;
class AlexaController extends Controller
@ -35,11 +35,11 @@ class AlexaController extends Controller
$logger->debug('Incoming Alexa Request', [
'type' => $type,
'intent' => $intent
'intent' => $intent,
]);
$logger->debug('Incoming Alexa Full Request', [
'json' => json_encode($request->json()->all(), JSON_PRETTY_PRINT)
'json' => json_encode($request->json()->all(), JSON_PRETTY_PRINT),
]);
/** @var JsonResponse $response */
@ -63,7 +63,7 @@ class AlexaController extends Controller
switch ($type) {
case 'LaunchRequest':
return $this->launch();
case 'PlayAudio';
case 'PlayAudio':
return $this->play();
case 'AudioPlayer.PlaybackNearlyFinished':
return $this->queueNextTrack();
@ -101,9 +101,9 @@ class AlexaController extends Controller
'version' => '1.0',
'sessionAttributes' => (object) [],
'response' => [
"outputSpeech" => [
"type" => "SSML",
"ssml" => "<speak>If you want to play music, say 'Alexa, ask pony fm to play'</speak>"
'outputSpeech' => [
'type' => 'SSML',
'ssml' => "<speak>If you want to play music, say 'Alexa, ask pony fm to play'</speak>",
],
'shouldEndSession' => true,
],
@ -116,9 +116,9 @@ class AlexaController extends Controller
'version' => '1.0',
'sessionAttributes' => (object) [],
'response' => [
"outputSpeech" => [
"type" => "SSML",
"ssml" => "<speak>Sorry, I don't recognise that command.</speak>"
'outputSpeech' => [
'type' => 'SSML',
'ssml' => "<speak>Sorry, I don't recognise that command.</speak>",
],
'shouldEndSession' => true,
],
@ -131,13 +131,13 @@ class AlexaController extends Controller
'version' => '1.0',
'sessionAttributes' => (object) [],
'response' => [
"outputSpeech" => [
"type" => "SSML",
"ssml" => "
'outputSpeech' => [
'type' => 'SSML',
'ssml' => '
<speak>
Pony.fm was built by Pixel Wavelength for Viola to keep all her music in one place.
</speak>
"
',
],
'shouldEndSession' => true,
],
@ -199,16 +199,16 @@ class AlexaController extends Controller
'version' => '1.0',
'sessionAttributes' => (object) [],
'response' => [
"outputSpeech" => [
"type" => "SSML",
"ssml" => "
'outputSpeech' => [
'type' => 'SSML',
'ssml' => "
<speak>
You've reached the end of the popular tracks today. To start from the beginning say 'Alexa, ask pony fm to play'
</speak>
"],
", ],
'directives' => [
[
'type' => 'AudioPlayer.Stop'
'type' => 'AudioPlayer.Stop',
],
],
'shouldEndSession' => true,
@ -247,7 +247,7 @@ class AlexaController extends Controller
'stream' => $stream,
],
],
]
],
],
];
}
@ -285,7 +285,7 @@ class AlexaController extends Controller
'stream' => $stream,
],
],
]
],
],
];
}
@ -298,7 +298,7 @@ class AlexaController extends Controller
'response' => [
'directives' => [
[
'type' => 'AudioPlayer.Stop'
'type' => 'AudioPlayer.Stop',
],
],
'shouldEndSession' => true,

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,15 +20,17 @@
namespace App\Http\Controllers\Api\Web;
use Carbon\Carbon;
use App\Commands\CreateAnnouncementCommand;
use App\Http\Controllers\Controller;
use App\Models\Announcement;
use Carbon\Carbon;
use Request;
use Response;
class AnnouncementsController extends Controller {
public function getIndex() {
class AnnouncementsController extends Controller
{
public function getIndex()
{
$currentDate = Carbon::now();
$query = Announcement::whereNotNull('start_time')
@ -40,23 +42,25 @@ class AnnouncementsController extends Controller {
$announcement = $query->first();
return Response::json(
["announcement" => $announcement],
['announcement' => $announcement],
200
);
}
public function getAdminIndex() {
public function getAdminIndex()
{
$this->authorize('access-admin-area');
$announcements = Announcement::orderBy('start_time', 'desc')
->get();
return Response::json([
'announcements' => $announcements->toArray()
'announcements' => $announcements->toArray(),
], 200);
}
public function getItemById($genreId) {
public function getItemById($genreId)
{
$this->authorize('access-admin-area');
$query = Announcement::where('id', '=', $genreId)
@ -65,13 +69,15 @@ class AnnouncementsController extends Controller {
$announcement = $query->first();
return Response::json(
["announcement" => $announcement],
['announcement' => $announcement],
200
);
}
public function postCreate() {
public function postCreate()
{
$command = new CreateAnnouncementCommand(Request::get('name'));
return $this->execute($command);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,21 +20,21 @@
namespace App\Http\Controllers\Api\Web;
use Gate;
use App;
use App\Commands\CreateUserCommand;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Album;
use App\Models\Comment;
use App\Models\Favourite;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Follower;
use App\Models\Image;
use App\Models\Track;
use App\Models\User;
use App\Models\Follower;
use App;
use ColorThief\ColorThief;
use Gate;
use Helpers;
use Illuminate\Support\Facades\Request;
use Response;
use ColorThief\ColorThief;
use Helpers;
class ArtistsController extends ApiControllerBase
{
@ -62,7 +62,7 @@ class ArtistsController extends ApiControllerBase
},
'album' => function ($query) {
$query->userDetails();
}
},
])->get();
$tracks = [];
@ -80,7 +80,7 @@ class ArtistsController extends ApiControllerBase
return Response::json([
'tracks' => $tracks,
'albums' => $albums
'albums' => $albums,
], 200);
}
@ -133,7 +133,7 @@ class ArtistsController extends ApiControllerBase
->with([
'comments' => function ($query) {
$query->with(['user', 'user.avatar']);
}
},
])
->first();
if (! $user) {
@ -162,18 +162,18 @@ class ArtistsController extends ApiControllerBase
}
$userData = [
'is_following' => false
'is_following' => false,
];
if ($user->users->count()) {
$userRow = $user->users[0];
$userData = [
'is_following' => (bool) $userRow->is_followed
'is_following' => (bool) $userRow->is_followed,
];
}
$palette = ColorThief::getPalette($user->getAvatarUrlLocal(Image::SMALL), 2);
$formatted_palette = array_map("Helpers::rgb2hex", $palette);
$formatted_palette = array_map('Helpers::rgb2hex', $palette);
$followers = Follower::where('artist_id', $user->id)
->count();
@ -186,7 +186,7 @@ class ArtistsController extends ApiControllerBase
'is_archived' => (bool) $user->is_archived,
'avatars' => [
'small' => $user->getAvatarUrl(Image::SMALL),
'normal' => $user->getAvatarUrl(Image::NORMAL)
'normal' => $user->getAvatarUrl(Image::NORMAL),
],
'avatar_colors' => $formatted_palette,
'created_at' => $user->created_at,
@ -199,10 +199,10 @@ class ArtistsController extends ApiControllerBase
'message_url' => $user->message_url,
'user_data' => $userData,
'permissions' => [
'edit' => Gate::allows('edit', $user)
'edit' => Gate::allows('edit', $user),
],
'isAdmin' => $user->hasRole('admin'),
],
'isAdmin' => $user->hasRole('admin')
]
], 200);
}
@ -228,7 +228,7 @@ class ArtistsController extends ApiControllerBase
}
return Response::json(
["artists" => $users, "current_page" => $page, "total_pages" => ceil($count / $perPage)],
['artists' => $users, 'current_page' => $page, 'total_pages' => ceil($count / $perPage)],
200
);
}
@ -236,6 +236,7 @@ class ArtistsController extends ApiControllerBase
public function postIndex()
{
$name = Request::json('username');
return $this->execute(new CreateUserCommand($name, $name, null, true));
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -22,8 +22,8 @@ namespace App\Http\Controllers\Api\Web;
use App;
use App\Commands\CreateCommentCommand;
use App\Models\Comment;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Comment;
use Illuminate\Support\Facades\Request;
use Response;

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -51,7 +51,7 @@ class DashboardController extends ApiControllerBase
return Response::json([
'recent_tracks' => $recentTracks,
'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content)
'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content),
], 200);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,10 @@
namespace App\Http\Controllers\Api\Web;
use App\Models\Album;
use App\Commands\ToggleFavouriteCommand;
use App\Models\Favourite;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Album;
use App\Models\Favourite;
use App\Models\Playlist;
use App\Models\Track;
use Auth;
@ -52,7 +52,7 @@ class FavouritesController extends ApiControllerBase
'track.genre',
'track.cover',
'track.album',
'track.album.user'
'track.album.user',
]);
$tracks = [];
@ -65,7 +65,7 @@ class FavouritesController extends ApiControllerBase
$tracks[] = Track::mapPublicTrackSummary($fav->track);
}
return Response::json(["tracks" => $tracks], 200);
return Response::json(['tracks' => $tracks], 200);
}
public function getAlbums()
@ -79,7 +79,7 @@ class FavouritesController extends ApiControllerBase
},
'album.user',
'album.user.avatar',
'album.cover'
'album.cover',
]);
$albums = [];
@ -92,7 +92,7 @@ class FavouritesController extends ApiControllerBase
$albums[] = Album::mapPublicAlbumSummary($fav->album);
}
return Response::json(["albums" => $albums], 200);
return Response::json(['albums' => $albums], 200);
}
public function getPlaylist()
@ -107,7 +107,7 @@ class FavouritesController extends ApiControllerBase
'playlist.user',
'playlist.user.avatar',
'playlist.tracks',
'playlist.tracks.cover'
'playlist.tracks.cover',
]);
$playlists = [];
@ -120,6 +120,6 @@ class FavouritesController extends ApiControllerBase
$playlists[] = Playlist::mapPublicPlaylistSummary($fav->playlist);
}
return Response::json(["playlists" => $playlists], 200);
return Response::json(['playlists' => $playlists], 200);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,12 +20,12 @@
namespace App\Http\Controllers\Api\Web;
use Illuminate\Support\Facades\Request;
use App\Commands\CreateGenreCommand;
use App\Commands\DeleteGenreCommand;
use App\Commands\RenameGenreCommand;
use App\Models\Genre;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Genre;
use Illuminate\Support\Facades\Request;
use Response;
class GenresController extends ApiControllerBase
@ -41,26 +41,28 @@ class GenresController extends ApiControllerBase
->get();
return Response::json([
'genres' => $genres->toArray()
'genres' => $genres->toArray(),
], 200);
}
public function postCreate()
{
$command = new CreateGenreCommand(Request::get('name'));
return $this->execute($command);
}
public function putRename($genreId)
{
$command = new RenameGenreCommand($genreId, Request::get('name'));
return $this->execute($command);
}
public function deleteGenre($genreId)
{
$command = new DeleteGenreCommand($genreId, Request::get('destination_genre_id'));
return $this->execute($command);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,10 @@
namespace App\Http\Controllers\Api\Web;
use Auth;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Image;
use App\Models\User;
use Auth;
use Response;
class ImagesController extends ApiControllerBase
@ -42,9 +42,9 @@ class ImagesController extends ApiControllerBase
'small' => $image->getUrl(Image::SMALL),
'normal' => $image->getUrl(Image::NORMAL),
'thumbnail' => $image->getUrl(Image::THUMBNAIL),
'original' => $image->getUrl(Image::ORIGINAL)
'original' => $image->getUrl(Image::ORIGINAL),
],
'filename' => $image->filename
'filename' => $image->filename,
];
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,13 +20,13 @@
namespace App\Http\Controllers\Api\Web;
use Auth;
use Illuminate\Support\Facades\Request;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Notification;
use App\Models\Subscription;
use App\Models\Track;
use App\Models\User;
use Auth;
use Illuminate\Support\Facades\Request;
use Minishlink\WebPush\WebPush;
class NotificationsController extends ApiControllerBase
@ -85,7 +85,7 @@ class NotificationsController extends ApiControllerBase
'user_id' => Auth::user()->id,
'endpoint' => $input->endpoint,
'p256dh' => $input->keys->p256dh,
'auth' => $input->keys->auth
'auth' => $input->keys->auth,
]);
return ['id' => $subscription->id];
@ -98,7 +98,7 @@ class NotificationsController extends ApiControllerBase
}
/**
* Removes a user's notification subscription
* Removes a user's notification subscription.
*
* @return string
*/

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,7 +20,6 @@
namespace App\Http\Controllers\Api\Web;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Commands\AddTrackToPlaylistCommand;
use App\Commands\CreatePlaylistCommand;
use App\Commands\DeletePlaylistCommand;
@ -30,11 +29,12 @@ use App\Http\Controllers\ApiControllerBase;
use App\Models\Image;
use App\Models\Playlist;
use App\Models\ResourceLogItem;
use Auth;
use Illuminate\Support\Facades\Request;
use App\Models\User;
use Response;
use App\Models\Track;
use App\Models\User;
use Auth;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request;
use Response;
class PlaylistsController extends ApiControllerBase
{
@ -95,9 +95,9 @@ class PlaylistsController extends ApiControllerBase
}
return Response::json([
"playlists" => $playlists,
"current_page" => $page,
"total_pages" => ceil($count / $perPage)
'playlists' => $playlists,
'current_page' => $page,
'total_pages' => ceil($count / $perPage),
], 200);
}
@ -113,7 +113,7 @@ class PlaylistsController extends ApiControllerBase
},
'tracks.trackFiles',
'comments',
'comments.user'
'comments.user',
])->userDetails()->find($id);
if (! $playlist || ! $playlist->canView(Auth::user())) {
App::abort('404');
@ -201,18 +201,17 @@ class PlaylistsController extends ApiControllerBase
'url' => $playlist->url,
'covers' => [
'small' => $playlist->getCoverUrl(Image::SMALL),
'normal' => $playlist->getCoverUrl(Image::NORMAL)
'normal' => $playlist->getCoverUrl(Image::NORMAL),
],
'is_pinned' => $playlist->hasPinFor(Auth::user()->id),
'is_public' => $playlist->is_public == 1,
'track_ids' => $playlist->tracks->pluck('id')
'track_ids' => $playlist->tracks->pluck('id'),
];
}
return Response::json($playlists, 200);
}
/**
* This function should not deal with anything other than applying order,
* which is done after the query's total possible results are counted due

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,10 @@
namespace App\Http\Controllers\Api\Web;
use Elasticsearch;
use App\Http\Controllers\ApiControllerBase;
use Illuminate\Support\Facades\Request;
use App\Library\Search;
use Elasticsearch;
use Illuminate\Support\Facades\Request;
use Response;
class SearchController extends ApiControllerBase

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,12 +20,12 @@
namespace App\Http\Controllers\Api\Web;
use Illuminate\Support\Facades\Request;
use App\Commands\CreateShowSongCommand;
use App\Commands\DeleteShowSongCommand;
use App\Commands\RenameShowSongCommand;
use App\Models\ShowSong;
use App\Http\Controllers\ApiControllerBase;
use App\Models\ShowSong;
use Illuminate\Support\Facades\Request;
use Response;
class ShowSongsController extends ApiControllerBase
@ -42,26 +42,28 @@ class ShowSongsController extends ApiControllerBase
->get();
return Response::json([
'showsongs' => $songs->toArray()
'showsongs' => $songs->toArray(),
], 200);
}
public function postCreate()
{
$command = new CreateShowSongCommand(Request::get('title'));
return $this->execute($command);
}
public function putRename($songId)
{
$command = new RenameShowSongCommand($songId, Request::get('title'));
return $this->execute($command);
}
public function deleteSong($songId)
{
$command = new DeleteShowSongCommand($songId, Request::get('destination_song_id'));
return $this->execute($command);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,15 +20,15 @@
namespace App\Http\Controllers\Api\Web;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Http\Controllers\ApiControllerBase;
use App\Models\ResourceLogItem;
use App\Models\Track;
use Auth;
use Cache;
use DB;
use Response;
use Carbon\Carbon;
use DB;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Response;
class StatsController extends ApiControllerBase
{
@ -88,12 +88,12 @@ class StatsController extends ApiControllerBase
if ($hourly) {
$set = [
'hours' => $timeOffet.' '.str_plural('hour', $timeOffet),
'plays' => $plays
'plays' => $plays,
];
} else {
$set = [
'days' => $timeOffet.' '.str_plural('day', $timeOffet),
'plays' => $plays
'plays' => $plays,
];
}
array_push($output, $set);
@ -134,6 +134,7 @@ class StatsController extends ApiControllerBase
$statsData = $this->getStatsData($id, $hourly);
$output = $this->sortTrackStatsArray($statsData, $hourly);
return $output;
});

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,8 +20,8 @@
namespace App\Http\Controllers\Api\Web;
use App\Models\Genre;
use App\Http\Controllers\ApiControllerBase;
use App\Models\Genre;
use App\Models\License;
use App\Models\ShowSong;
use App\Models\TrackType;
@ -48,7 +48,7 @@ class TaxonomiesController extends ApiControllerBase
'id',
'slug',
DB::raw('(SELECT COUNT(tracks.id) FROM show_song_track INNER JOIN tracks ON tracks.id = show_song_track.track_id WHERE show_song_track.show_song_id = show_songs.id AND tracks.published_at IS NOT NULL) AS track_count')
)->orderBy('title')->get()->toArray()
)->orderBy('title')->get()->toArray(),
], 200);
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,10 +20,6 @@
namespace App\Http\Controllers\Api\Web;
use Auth;
use File;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request;
use App\Commands\DeleteTrackCommand;
use App\Commands\EditTrackCommand;
use App\Commands\GenerateTrackFilesCommand;
@ -33,9 +29,13 @@ use App\Jobs\EncodeTrackFile;
use App\Models\Genre;
use App\Models\ResourceLogItem;
use App\Models\Track;
use App\Models\TrackType;
use App\Models\TrackFile;
use App\Models\TrackType;
use App\Models\User;
use Auth;
use File;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request;
use Response;
use Symfony\Component\HttpFoundation\File\UploadedFile;
@ -85,6 +85,7 @@ class TracksController extends ApiControllerBase
$track->version_upload_status = Track::STATUS_PROCESSING;
$track->update();
return $this->execute(new UploadTrackCommand(true, false, null, false, $track->getNextVersion(), $track));
}
@ -114,7 +115,7 @@ class TracksController extends ApiControllerBase
$versions[] = [
'version' => $trackFile->version,
'url' => '/tracks/'.$track->id.'/version-change/'.$trackFile->version,
'created_at' => $trackFile->created_at->timestamp
'created_at' => $trackFile->created_at->timestamp,
];
}
@ -137,6 +138,7 @@ class TracksController extends ApiControllerBase
$track->version_upload_status = Track::STATUS_PROCESSING;
$track->update();
$sourceFile = new UploadedFile($masterTrackFile->getFile(), $masterTrackFile->getFilename());
return $this->execute(new GenerateTrackFilesCommand($track, $sourceFile, false, false, true, $newVersion));
}
@ -239,21 +241,23 @@ class TracksController extends ApiControllerBase
}
return Response::json([
"tracks" => $tracks,
"current_page" => $page,
"total_pages" => ceil($totalCount / $perPage)
'tracks' => $tracks,
'current_page' => $page,
'total_pages' => ceil($totalCount / $perPage),
], 200);
}
public function getAllTracks()
{
$this->authorize('access-admin-area');
return $this->getIndex(true);
}
public function getClassifierQueue()
{
$this->authorize('access-admin-area');
return $this->getIndex(true, true);
}
@ -355,9 +359,10 @@ class TracksController extends ApiControllerBase
$archives = ['mlpma', 'ponify', 'eqbeats'];
$akey = array_search($archive, $archives);
if (!$akey)
if (! $akey) {
$query->join($archive.'_tracks', 'tracks.id', '=', $archive.'tracks.track_id');
}
}
if (Request::has('songs')) {
// DISTINCT is needed here to avoid duplicate results

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -42,7 +42,7 @@ abstract class ApiControllerBase extends Controller
if ($result->didFail()) {
return Response::json([
'message' => 'Validation failed',
'errors' => $result->getMessages()
'errors' => $result->getMessages(),
], $result->getStatusCode());
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -22,8 +22,8 @@ namespace App\Http\Controllers;
use App;
use App\Models\User;
use View;
use Redirect;
use View;
class ArtistsController extends Controller
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,18 +20,18 @@
namespace App\Http\Controllers;
use App\Models\Activity;
use App\Models\User;
use Auth;
use Carbon\Carbon;
use DB;
use Illuminate\Support\Facades\Input;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
use Log;
use Poniverse\Lib\Client;
use App\Models\Activity;
use App\Models\User;
use Auth;
use DB;
use Request;
use Redirect;
use Request;
class AuthController extends Controller
{
@ -57,6 +57,7 @@ class AuthController extends Controller
public function postLogout()
{
Auth::logout();
return Redirect::to('/');
}
@ -67,7 +68,7 @@ class AuthController extends Controller
try {
$accessToken = $oauthProvider->getAccessToken('authorization_code', [
'code' => Request::query('code'),
'redirect_uri' => action('AuthController@getOAuth')
'redirect_uri' => action('AuthController@getOAuth'),
]);
$this->poniverse->setAccessToken($accessToken);
$resourceOwner = $oauthProvider->getResourceOwner($accessToken);
@ -101,6 +102,7 @@ class AuthController extends Controller
if ($token) {
//User already exists, update access token and refresh token if provided.
DB::table('oauth2_tokens')->where('id', '=', $token->id)->update($setData);
return $this->loginRedirect(User::find($token->user_id));
}
@ -120,7 +122,6 @@ class AuthController extends Controller
}
}
return $this->loginRedirect($user);
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -22,8 +22,8 @@ namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,9 +20,9 @@
namespace App\Http\Controllers;
use App;
use App\Models\Image;
use Config;
use App;
use Redirect;
use Response;

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Feld0
* Copyright (C) 2016 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -21,19 +21,20 @@
namespace App\Http\Controllers;
use App;
use Auth;
use DB;
use App\Models\Email;
use App\Models\EmailSubscription;
use Auth;
use DB;
use View;
class NotificationsController extends Controller {
class NotificationsController extends Controller
{
/**
* @param $emailKey
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function getEmailClick($emailKey) {
public function getEmailClick($emailKey)
{
/** @var Email $email */
$email = Email::findOrFail($emailKey);
@ -46,7 +47,8 @@ class NotificationsController extends Controller {
return redirect($email->getActivity()->url);
}
public function getEmailUnsubscribe($subscriptionKey) {
public function getEmailUnsubscribe($subscriptionKey)
{
/** @var EmailSubscription $subscription */
$subscription = EmailSubscription::findOrFail($subscriptionKey);
$subscription->delete();
@ -54,17 +56,18 @@ class NotificationsController extends Controller {
if (Auth::check() && $subscription->user->id === Auth::user()->id) {
return redirect(route('account:settings', [
'slug' => $subscription->user->slug,
'unsubscribedMessageKey' => $subscription->activity_type
'unsubscribedMessageKey' => $subscription->activity_type,
]), 303);
} else {
return redirect(route('email:confirm-unsubscribed', [
'unsubscribedUser' => $subscription->user->display_name,
'unsubscribedMessageKey' => $subscription->activity_type
'unsubscribedMessageKey' => $subscription->activity_type,
]), 303);
}
}
public function getEmailUnsubscribePage() {
public function getEmailUnsubscribePage()
{
return View::make('shared.null');
}
}

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2016 Logic
* Copyright (C) 2016 Logic.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,13 +20,13 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App;
use App\Models\ResourceLogItem;
use App\Models\Track;
use App\Models\TrackFile;
use Auth;
use Config;
use App;
use Illuminate\Http\Request;
use Redirect;
use Response;
use View;
@ -58,9 +58,9 @@ class TracksController extends Controller
'stats' => [
'views' => 0,
'plays' => 0,
'downloads' => 0
'downloads' => 0,
],
'is_favourited' => false
'is_favourited' => false,
];
if ($track->users->count()) {
@ -71,7 +71,7 @@ class TracksController extends Controller
'plays' => $userRow->play_count,
'downloads' => $userRow->download_count,
],
'is_favourited' => $userRow->is_favourited
'is_favourited' => $userRow->is_favourited,
];
}
@ -107,7 +107,7 @@ class TracksController extends Controller
'title' => $track->title,
'author_name' => $track->user->display_name,
'author_url' => $track->user->url,
'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>'
'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
];
return Response::json($output);

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -42,7 +42,7 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\App\Http\Middleware\DisabledAccountCheck::class,
]
],
];
/**

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -20,6 +20,7 @@
namespace App\Http\Middleware;
use App\Models\User;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
@ -27,7 +28,6 @@ use Illuminate\Session\Store;
use League\OAuth2\Client\Token\AccessToken;
use Poniverse;
use Poniverse\Lib\Client;
use App\Models\User;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class AuthenticateOAuth
@ -92,7 +92,6 @@ class AuthenticateOAuth
return $next($request);
}
private function determineAccessToken(Request $request, $headerOnly = true)
{
$header = $request->header('Authorization');

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -43,8 +43,6 @@ class DisabledAccountCheck
$this->auth = $auth;
}
/**
* Handle an incoming request.
*

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by

View file

@ -2,7 +2,7 @@
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015 Feld0
* Copyright (C) 2015 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -24,11 +24,7 @@ use Closure;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Class JsonExceptions
* @package App\Http\Middleware
*
* This middleware turns any HTTP exceptions thrown during the request
* into a JSON response. To be used when implementing the API!
* Class JsonExceptions.
*/
class JsonExceptions
{
@ -45,7 +41,7 @@ class JsonExceptions
$response = $next($request);
} catch (HttpException $e) {
return \Response::json([
'message' => $e->getMessage()
'message' => $e->getMessage(),
], $e->getStatusCode());
}

Some files were not shown because too many files have changed in this diff Show more