Merge pull request #147 from Poniverse/shift-40778

This commit is contained in:
Adam Lavin 2021-02-14 18:20:20 +00:00 committed by GitHub
commit bcc42c397b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 706 additions and 418 deletions

View file

@ -8,6 +8,7 @@ use App\Models\Track;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Session\Store;
use Illuminate\Support\Arr;
use Psr\Log\LoggerInterface;
class AlexaController extends Controller
@ -146,7 +147,7 @@ class AlexaController extends Controller
public function play()
{
$track = array_first(Track::popular(1));
$track = Arr::first(Track::popular(1));
$this->session->put('current_position', 1);
$this->session->put('track_id', $track['id']);

View file

@ -28,6 +28,7 @@ use Cache;
use Carbon\Carbon;
use DB;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Str;
use Response;
class StatsController extends ApiControllerBase
@ -87,12 +88,12 @@ class StatsController extends ApiControllerBase
foreach ($playsArray as $timeOffet => $plays) {
if ($hourly) {
$set = [
'hours' => $timeOffet.' '.str_plural('hour', $timeOffet),
'hours' => $timeOffet.' '.Str::plural('hour', $timeOffet),
'plays' => $plays,
];
} else {
$set = [
'days' => $timeOffet.' '.str_plural('day', $timeOffet),
'days' => $timeOffet.' '.Str::plural('day', $timeOffet),
'plays' => $plays,
];
}
@ -108,7 +109,7 @@ class StatsController extends ApiControllerBase
public function getTrackStats($id)
{
$cachedOutput = Cache::remember('track_stats'.$id, 5, function () use ($id) {
$cachedOutput = Cache::remember('track_stats'.$id, 300, function () use ($id) {
try {
$track = Track::published()->findOrFail($id);
} catch (ModelNotFoundException $e) {

View file

@ -93,7 +93,6 @@ class Album extends Model implements Searchable, Commentable, Favouritable
protected $elasticsearchType = 'album';
protected $dates = ['deleted_at'];
protected $fillable = ['user_id', 'title', 'slug'];
public static function summary()

View file

@ -72,8 +72,6 @@ class Comment extends Model
protected $table = 'comments';
protected $dates = ['deleted_at'];
public function user()
{
return $this->belongsTo(User::class);

View file

@ -95,7 +95,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
protected $elasticsearchType = 'playlist';
protected $table = 'playlists';
protected $dates = ['deleted_at'];
protected $casts = [
'id' => 'integer',
'user_id' => 'integer',

View file

@ -152,7 +152,9 @@ class Track extends Model implements Searchable, Commentable, Favouritable
protected $elasticsearchType = 'track';
protected $dates = ['deleted_at', 'published_at', 'released_at'];
protected $dates = [
'published_at', 'released_at',
];
protected $hidden = ['original_tags', 'metadata'];
protected $casts = [
'id' => 'integer',
@ -385,7 +387,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
{
$trackData = Cache::remember(
'popular_tracks'.$count.'-'.($allowExplicit ? 'explicit' : 'safe'),
5,
300,
function () use ($allowExplicit, $count, $skip) {
/*$query = static
::published()

View file

@ -170,7 +170,7 @@ trait TrackCollection
return 0;
}
return Cache::remember($this->getCacheKey('filesize-'.$format), 1440, function () use ($tracks, $format) {
return Cache::remember($this->getCacheKey('filesize-'.$format), 86400, function () use ($tracks, $format) {
$size = 0;
// Check whether the format is lossless yet not all master files are lossless

View file

@ -11,13 +11,13 @@
"type": "project",
"require": {
"php": "^7.1.3",
"laravel/framework": "5.7.*",
"laravel/framework": "5.8.*",
"codescale/ffmpeg-php": "2.7.0",
"barryvdh/laravel-ide-helper": "v2.8.0",
"guzzlehttp/guzzle": "~6.0",
"doctrine/dbal": "2.5.*",
"venturecraft/revisionable": "^1.36",
"pda/pheanstalk": "~3.0",
"pda/pheanstalk": "~v4.0.0",
"cviebrock/laravel-elasticsearch": "4.0.0",
"barryvdh/laravel-debugbar": "~3.4",
"predis/predis": "^1.0",
@ -31,19 +31,19 @@
"doctrine/collections": "v1.4.*",
"doctrine/annotations": "v1.4.*",
"doctrine/cache": "v1.6.*",
"doctrine/instantiator": "1.0.*",
"doctrine/instantiator": "^1.1",
"fideloper/proxy": "^4.0"
},
"require-dev": {
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5",
"filp/whoops": "^2.0",
"symfony/dom-crawler": "~3.1",
"symfony/css-selector": "~3.1",
"laravel/browser-kit-testing": "2.*",
"nategood/httpful": "^0.2.20",
"nunomaduro/collision": "^2.0",
"nunomaduro/collision": "^3.0",
"beyondcode/laravel-dump-server": "^1.0"
},
"autoload": {

857
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -179,6 +179,8 @@ return [
*/
'aliases' => [
'Str' => Illuminate\Support\Str::class,
'Arr' => Illuminate\Support\Arr::class,
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,

View file

@ -13,7 +13,8 @@ return [
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/
@ -75,6 +76,15 @@ return [
'connection' => 'cache',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
],
/*

View file

@ -1,5 +1,7 @@
<?php
use Illuminate\Support\Str;
return [
/*
@ -35,6 +37,7 @@ return [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
@ -42,6 +45,7 @@ return [
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
@ -54,10 +58,14 @@ return [
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
@ -72,6 +80,7 @@ return [
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
@ -110,9 +119,15 @@ return [
'redis' => [
'client' => 'predis',
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
@ -120,6 +135,7 @@ return [
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),

View file

@ -12,7 +12,7 @@ return [
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
| "sparkpost", "log", "array"
| "sparkpost", "postmark", "log", "array"
|
*/

View file

@ -46,15 +46,16 @@ return [
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('SQS_KEY', 'your-public-key'),
'secret' => env('SQS_SECRET', 'your-secret-key'),
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('SQS_REGION', 'us-east-1'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'redis' => [

View file

@ -8,9 +8,9 @@ return [
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
| as Mailgun, SparkPost and others. This file provides a sane default
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
@ -20,24 +20,18 @@ return [
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => env('SES_REGION', 'us-east-1'),
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\Models\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
'webhook' => [
'secret' => env('STRIPE_WEBHOOK_SECRET'),
'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
],
],
];

View file

@ -14,7 +14,7 @@ return [
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "array"
| "memcached", "redis", "dynamodb", "array"
|
*/
@ -92,9 +92,9 @@ return [
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using the "apc" or "memcached" session drivers, you may specify a
| cache store that should be used for these sessions. This value must
| correspond with one of the application's configured cache stores.
| When using the "apc", "memcached", or "dynamodb" session drivers you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
*/

View file

@ -16,11 +16,13 @@ return [
'accepted' => 'The :attribute must be accepted.',
'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.',
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
'alpha' => 'The :attribute may only contain letters.',
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.',
'alpha_num' => 'The :attribute may only contain letters and numbers.',
'array' => 'The :attribute must be an array.',
'before' => 'The :attribute must be a date before :date.',
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
'between' => [
'numeric' => 'The :attribute must be between :min and :max.',
'file' => 'The :attribute must be between :min and :max kilobytes.',
@ -30,20 +32,50 @@ return [
'boolean' => 'The :attribute field must be true or false.',
'confirmed' => 'The :attribute confirmation does not match.',
'date' => 'The :attribute is not a valid date.',
'date_equals' => 'The :attribute must be a date equal to :date.',
'date_format' => 'The :attribute does not match the format :format.',
'different' => 'The :attribute and :other must be different.',
'digits' => 'The :attribute must be :digits digits.',
'digits_between' => 'The :attribute must be between :min and :max digits.',
'dimensions' => 'The :attribute has invalid image dimensions.',
'distinct' => 'The :attribute field has a duplicate value.',
'email' => 'The :attribute must be a valid email address.',
'ends_with' => 'The :attribute must end with one of the following: :values',
'exists' => 'The selected :attribute is invalid.',
'filled' => 'The :attribute field is required.',
'file' => 'The :attribute must be a file.',
'filled' => 'The :attribute field must have a value.',
'gt' => [
'numeric' => 'The :attribute must be greater than :value.',
'file' => 'The :attribute must be greater than :value kilobytes.',
'string' => 'The :attribute must be greater than :value characters.',
'array' => 'The :attribute must have more than :value items.',
],
'gte' => [
'numeric' => 'The :attribute must be greater than or equal :value.',
'file' => 'The :attribute must be greater than or equal :value kilobytes.',
'string' => 'The :attribute must be greater than or equal :value characters.',
'array' => 'The :attribute must have :value items or more.',
],
'image' => 'The :attribute must be an image.',
'in' => 'The selected :attribute is invalid.',
'in_array' => 'The :attribute field does not exist in :other.',
'integer' => 'The :attribute must be an integer.',
'ip' => 'The :attribute must be a valid IP address.',
'ipv4' => 'The :attribute must be a valid IPv4 address.',
'ipv6' => 'The :attribute must be a valid IPv6 address.',
'json' => 'The :attribute must be a valid JSON string.',
'lt' => [
'numeric' => 'The :attribute must be less than :value.',
'file' => 'The :attribute must be less than :value kilobytes.',
'string' => 'The :attribute must be less than :value characters.',
'array' => 'The :attribute must have less than :value items.',
],
'lte' => [
'numeric' => 'The :attribute must be less than or equal :value.',
'file' => 'The :attribute must be less than or equal :value kilobytes.',
'string' => 'The :attribute must be less than or equal :value characters.',
'array' => 'The :attribute must not have more than :value items.',
],
'max' => [
'numeric' => 'The :attribute may not be greater than :max.',
'file' => 'The :attribute may not be greater than :max kilobytes.',
@ -51,6 +83,7 @@ return [
'array' => 'The :attribute may not have more than :max items.',
],
'mimes' => 'The :attribute must be a file of type: :values.',
'mimetypes' => 'The :attribute must be a file of type: :values.',
'min' => [
'numeric' => 'The :attribute must be at least :min.',
'file' => 'The :attribute must be at least :min kilobytes.',
@ -58,6 +91,7 @@ return [
'array' => 'The :attribute must have at least :min items.',
],
'not_in' => 'The selected :attribute is invalid.',
'not_regex' => 'The :attribute format is invalid.',
'numeric' => 'The :attribute must be a number.',
'present' => 'The :attribute field must be present.',
'regex' => 'The :attribute format is invalid.',
@ -65,7 +99,7 @@ return [
'required_if' => 'The :attribute field is required when :other is :value.',
'required_unless' => 'The :attribute field is required unless :other is in :values.',
'required_with' => 'The :attribute field is required when :values is present.',
'required_with_all' => 'The :attribute field is required when :values is present.',
'required_with_all' => 'The :attribute field is required when :values are present.',
'required_without' => 'The :attribute field is required when :values is not present.',
'required_without_all' => 'The :attribute field is required when none of :values are present.',
'same' => 'The :attribute and :other must match.',
@ -75,10 +109,13 @@ return [
'string' => 'The :attribute must be :size characters.',
'array' => 'The :attribute must contain :size items.',
],
'starts_with' => 'The :attribute must start with one of the following: :values',
'string' => 'The :attribute must be a string.',
'timezone' => 'The :attribute must be a valid zone.',
'unique' => 'The :attribute has already been taken.',
'uploaded' => 'The :attribute failed to upload.',
'url' => 'The :attribute format is invalid.',
'uuid' => 'The :attribute must be a valid UUID.',
/*
|--------------------------------------------------------------------------

View file

@ -19,7 +19,7 @@
@extends('shared._app_layout')
@section('title'){{ $track->title }} - {{ $track->user->display_name }} | @endsection
@section('description'){{ str_limit($track->description, $limit = 200, $end = '...') }}@endsection
@section('description'){{ Str::limit($track->description, $limit = 200, $end = '...') }}@endsection
@section('metadata')
<meta property="og:title" content="{{ $track->title }}" />
@ -28,7 +28,7 @@
<meta property="og:image" content="{{ $track->getCoverUrl(\App\Models\Image::NORMAL) }}" />
<meta property="og:image:width" content="350" />
<meta property="og:image:height" content="350" />
<meta property="og:description" content="{{ str_limit($track->description, $limit = 200, $end = '...') }}">
<meta property="og:description" content="{{ Str::limit($track->description, $limit = 200, $end = '...') }}">
<meta property="og:site_name" content="Pony.fm" />
<meta property="og:audio" content="{{ $track->getStreamUrl('MP3') }}" />
<meta property="og:audio:secure_url" content="{{ $track->getStreamUrl('MP3') }}" />
@ -39,7 +39,7 @@
<meta name="twitter:card" content="player" />
<meta name="twitter:site" content="@ponyfm" />
<meta name="twitter:title" content="{{ $track->title }}" />
<meta name="twitter:description" content="{{ str_limit($track->description, $limit = 200, $end = '...') }}" />
<meta name="twitter:description" content="{{ Str::limit($track->description, $limit = 200, $end = '...') }}" />
<meta name="twitter:image" content="{{ $track->getCoverUrl(\App\Models\Image::NORMAL) }}" />
<meta name="twitter:player" content="{{ url('t' . $track->id . '/embed?twitter') }}" />
<meta name="twitter:player:width" content="480" />

View file

@ -104,7 +104,7 @@ class TestCase extends BaseTestCase
}
}
public function tearDown()
protected function tearDown(): void
{
Storage::disk('local')->deleteDirectory('testing-datastore');
parent::tearDown();