diff --git a/app/Actions/Models/Aggregate/SyncViewAggregatesAction.php b/app/Actions/Models/Aggregate/SyncViewAggregatesAction.php deleted file mode 100644 index 5db158298..000000000 --- a/app/Actions/Models/Aggregate/SyncViewAggregatesAction.php +++ /dev/null @@ -1,45 +0,0 @@ -getMessage() - ); - } - - return new ActionResult( - ActionStatus::PASSED, - 'View aggregates synced successfully', - ); - } -} diff --git a/app/Actions/Storage/Admin/Dump/DumpViewAction.php b/app/Actions/Storage/Admin/Dump/DumpViewAction.php deleted file mode 100644 index 168f1b8a4..000000000 --- a/app/Actions/Storage/Admin/Dump/DumpViewAction.php +++ /dev/null @@ -1,48 +0,0 @@ -path('')) - ->append(DumpViewAction::FILENAME_PREFIX) - ->append(strval(Date::now()->valueOf())) - ->append('.sql') - ->__toString(); - } -} diff --git a/app/Concerns/GraphQL/ResolvesArguments.php b/app/Concerns/GraphQL/ResolvesArguments.php index 744dfd34f..a08d74215 100644 --- a/app/Concerns/GraphQL/ResolvesArguments.php +++ b/app/Concerns/GraphQL/ResolvesArguments.php @@ -11,12 +11,9 @@ use App\Contracts\GraphQL\Fields\RequiredOnCreation; use App\Contracts\GraphQL\Fields\RequiredOnUpdate; use App\Contracts\GraphQL\Fields\UpdatableField; use App\GraphQL\Schema\Fields\Field; -use App\GraphQL\Schema\Types\BaseType; use App\GraphQL\Support\Argument\Argument; use App\GraphQL\Support\Argument\BindableArgument; -use App\GraphQL\Support\Argument\SortArgument; use App\GraphQL\Support\Filter\Filter; -use Illuminate\Support\Arr; trait ResolvesArguments { @@ -58,16 +55,6 @@ trait ResolvesArguments ->toArray(); } - /** - * Resolve the fields into arguments that are used for sorting. - * - * @return SortArgument[] - */ - protected function resolveSortArguments(BaseType $type): array - { - return Arr::wrap(new SortArgument($type)); - } - /** * Resolve the fields into arguments that are used for mutations of type create. * diff --git a/app/Console/Commands/Models/SyncViewAggregatesCommand.php b/app/Console/Commands/Models/SyncViewAggregatesCommand.php deleted file mode 100644 index 265c3e479..000000000 --- a/app/Console/Commands/Models/SyncViewAggregatesCommand.php +++ /dev/null @@ -1,34 +0,0 @@ -handle(); - - $result->toLog(); - $result->toConsole($this); - - return $result->hasFailed() ? 1 : 0; - } - - protected function validator(): Validator - { - return ValidatorFacade::make($this->options(), []); - } -} diff --git a/app/Console/Commands/Storage/Admin/ViewDumpCommand.php b/app/Console/Commands/Storage/Admin/ViewDumpCommand.php deleted file mode 100644 index 35c90caad..000000000 --- a/app/Console/Commands/Storage/Admin/ViewDumpCommand.php +++ /dev/null @@ -1,35 +0,0 @@ -options()); - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e3d79bf07..b145191db 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace App\Console; use App\Console\Commands\Models\SyncLikeAggregatesCommand; -use App\Console\Commands\Models\SyncViewAggregatesCommand; use App\Console\Commands\Repositories\Storage\Admin\DumpReconcileCommand; use App\Console\Commands\Storage\Admin\AdminDumpCommand; use App\Console\Commands\Storage\Admin\AuthDumpCommand; @@ -159,12 +158,6 @@ class Kernel extends ConsoleKernel ->storeOutput() ->daily(); - $schedule->command(SyncViewAggregatesCommand::class) - ->withoutOverlapping() - ->runInBackground() - ->storeOutput() - ->weekly(); - $schedule->command(UpdateDisposableDomainsCommand::class) ->withoutOverlapping() ->runInBackground() diff --git a/app/Constants/FeatureConstants.php b/app/Constants/FeatureConstants.php index 9402288a4..e8050b2a0 100644 --- a/app/Constants/FeatureConstants.php +++ b/app/Constants/FeatureConstants.php @@ -8,8 +8,6 @@ class FeatureConstants { final public const ALLOW_DISCORD_NOTIFICATIONS = 'allow_discord_notifications'; - final public const ALLOW_VIEW_RECORDING = 'allow_view_recording'; - final public const AUDIO_BITRATE_RESTRICTION = 'audio_bitrate_restriction'; final public const ENABLED_ONLY_ON_LOCALHOST = 'enabled_only_on_localhost'; diff --git a/app/Filament/Providers/GlobalSearchScoutProvider.php b/app/Filament/Providers/GlobalSearchScoutProvider.php index 6c17c1bbd..77464f6b6 100644 --- a/app/Filament/Providers/GlobalSearchScoutProvider.php +++ b/app/Filament/Providers/GlobalSearchScoutProvider.php @@ -43,10 +43,10 @@ class GlobalSearchScoutProvider implements GlobalSearchProvider } return new GlobalSearchResult( - title: $resource::getGlobalSearchResultTitle($record), - url: $url, - details: $resource::getGlobalSearchResultDetails($record), - actions: $resource::getGlobalSearchResultActions($record), + $resource::getGlobalSearchResultTitle($record), + $url, + $resource::getGlobalSearchResultDetails($record), + $resource::getGlobalSearchResultActions($record), ); }) ->filter(); diff --git a/app/GraphQL/Schema/Fields/Wiki/Audio/AudioViewsCountField.php b/app/GraphQL/Schema/Fields/Wiki/Audio/AudioViewsCountField.php index 2da157b67..c95d7dbac 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Audio/AudioViewsCountField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Audio/AudioViewsCountField.php @@ -22,6 +22,6 @@ class AudioViewsCountField extends CountAggregateField implements DeprecatedFiel public function deprecationReason(): string { - return 'We will no longer track views.'; + return 'We are no longer tracking views.'; } } diff --git a/app/GraphQL/Schema/Fields/Wiki/Video/VideoViewsCountField.php b/app/GraphQL/Schema/Fields/Wiki/Video/VideoViewsCountField.php index 958938425..be49bf862 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Video/VideoViewsCountField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Video/VideoViewsCountField.php @@ -22,6 +22,6 @@ class VideoViewsCountField extends CountAggregateField implements DeprecatedFiel public function deprecationReason(): string { - return 'We will no longer track views. Use likesCount instead'; + return 'We are no longer tracking views. Use likesCount instead'; } } diff --git a/app/GraphQL/Schema/Queries/BaseQuery.php b/app/GraphQL/Schema/Queries/BaseQuery.php index 920866b48..f8726f51a 100644 --- a/app/GraphQL/Schema/Queries/BaseQuery.php +++ b/app/GraphQL/Schema/Queries/BaseQuery.php @@ -12,6 +12,7 @@ use App\GraphQL\Schema\Types\BaseType; use App\GraphQL\Support\Argument\Argument; use App\GraphQL\Support\Argument\FirstArgument; use App\GraphQL\Support\Argument\PageArgument; +use App\GraphQL\Support\Argument\SortArgument; use GraphQL\Type\Definition\Type; use Illuminate\Support\Arr; use Rebing\GraphQL\Support\Facades\GraphQL; @@ -69,7 +70,7 @@ abstract class BaseQuery extends Query } if ($baseType instanceof BaseType && $this instanceof EloquentPaginationQuery) { - $arguments[] = $this->resolveSortArguments($baseType); + $arguments[] = new SortArgument($baseType); } return Arr::flatten($arguments); diff --git a/app/GraphQL/Support/Filter/Filter.php b/app/GraphQL/Support/Filter/Filter.php index fdfdb8117..0eebd89d7 100644 --- a/app/GraphQL/Support/Filter/Filter.php +++ b/app/GraphQL/Support/Filter/Filter.php @@ -9,6 +9,7 @@ use App\GraphQL\Schema\Fields\Field; use App\GraphQL\Schema\Types\BaseType; use App\GraphQL\Support\Argument\Argument; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Collection; abstract class Filter { @@ -17,7 +18,7 @@ abstract class Filter protected mixed $defaultValue = null, ) {} - public static function getValueWithResolvers(BaseType $baseType) + public static function getValueWithResolvers(BaseType $baseType): Collection { return collect($baseType->fieldClasses()) ->filter(fn (Field $field) => $field instanceof FilterableField) diff --git a/app/GraphQL/Support/Relations/Relation.php b/app/GraphQL/Support/Relations/Relation.php index 95058ca6a..14bf719ed 100644 --- a/app/GraphQL/Support/Relations/Relation.php +++ b/app/GraphQL/Support/Relations/Relation.php @@ -13,6 +13,7 @@ use App\GraphQL\Schema\Unions\BaseUnion; use App\GraphQL\Support\Argument\Argument; use App\GraphQL\Support\Argument\FirstArgument; use App\GraphQL\Support\Argument\PageArgument; +use App\GraphQL\Support\Argument\SortArgument; use App\GraphQL\Support\Argument\TrashedArgument; use GraphQL\Type\Definition\Type; use Illuminate\Database\Eloquent\Model; @@ -94,7 +95,7 @@ abstract class Relation $arguments[] = new PageArgument(); if ($type instanceof BaseType) { - $arguments[] = $this->resolveSortArguments($this->baseType); + $arguments[] = new SortArgument($type); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 77f9847dc..ca56f8317 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -8,7 +8,6 @@ use App\Http\Middleware\Api\SetAcceptJsonHeader; use App\Http\Middleware\Auth\Authenticate; use App\Http\Middleware\Auth\RedirectIfAuthenticated; use App\Http\Middleware\LogRequest; -use App\Http\Middleware\Models\RecordView; use App\Http\Middleware\ThrottleRequestsWithService; use App\Http\Middleware\TrimStrings; use App\Http\Middleware\TrustHosts; @@ -106,7 +105,6 @@ class Kernel extends HttpKernel 'can' => Authorize::class, 'guest' => RedirectIfAuthenticated::class, 'password.confirm' => RequirePassword::class, - 'record_view' => RecordView::class, 'signed' => ValidateSignature::class, 'throttle' => ThrottleRequestsWithService::class, 'verified' => EnsureEmailIsVerified::class, diff --git a/app/Http/Middleware/Models/RecordView.php b/app/Http/Middleware/Models/RecordView.php deleted file mode 100644 index eeb1d3e58..000000000 --- a/app/Http/Middleware/Models/RecordView.php +++ /dev/null @@ -1,48 +0,0 @@ -model = $request->route($modelKey); - - if (! $this->model instanceof Viewable) { - throw new RuntimeException('record_view should only be configured for viewable models'); - } - - return $next($request); - } - - /** - * Handle tasks after the response has been sent to the browser. - */ - public function terminate(Request $request, Response $response): void - { - if (Feature::for(null)->active(FeatureConstants::ALLOW_VIEW_RECORDING) && $this->model instanceof Viewable) { - views($this->model)->cooldown(now()->addMinutes(5))->record(); - } - } -} diff --git a/app/Models/Aggregate/ViewAggregate.php b/app/Models/Aggregate/ViewAggregate.php index e54a26258..6a611e115 100644 --- a/app/Models/Aggregate/ViewAggregate.php +++ b/app/Models/Aggregate/ViewAggregate.php @@ -4,12 +4,11 @@ declare(strict_types=1); namespace App\Models\Aggregate; -use CyrildeWit\EloquentViewable\Contracts\Viewable; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; /** - * @property Viewable $viewable + * @property Model $viewable * @property string $viewable_type * @property int $viewable_id * @property int $value diff --git a/app/Models/List/Playlist.php b/app/Models/List/Playlist.php index 90854d2c0..e4afbf2cb 100644 --- a/app/Models/List/Playlist.php +++ b/app/Models/List/Playlist.php @@ -65,7 +65,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm final public const RELATION_LAST = 'last'; final public const RELATION_TRACKS = 'tracks'; final public const RELATION_USER = 'user'; - final public const RELATION_VIEWS = 'views'; /** * Is auditing disabled? diff --git a/app/Models/Service/View.php b/app/Models/Service/View.php deleted file mode 100644 index cd863173a..000000000 --- a/app/Models/Service/View.php +++ /dev/null @@ -1,44 +0,0 @@ -user_agent = Request::userAgent(); - $view->user_id = Auth::id(); - $view->referer = Request::header('referer'); - }); - } - - /** - * @return BelongsTo - */ - public function user(): BelongsTo - { - return $this->belongsTo(User::class, 'user_id'); - } -} diff --git a/app/Models/Wiki/Audio.php b/app/Models/Wiki/Audio.php index e67cee8c4..ba9046dfc 100644 --- a/app/Models/Wiki/Audio.php +++ b/app/Models/Wiki/Audio.php @@ -16,8 +16,6 @@ use App\Events\Wiki\Audio\AudioForceDeleting; use App\Events\Wiki\Audio\AudioRestored; use App\Events\Wiki\Audio\AudioUpdated; use App\Models\BaseModel; -use CyrildeWit\EloquentViewable\Contracts\Viewable; -use CyrildeWit\EloquentViewable\InteractsWithViews; use Database\Factories\Wiki\AudioFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -35,11 +33,10 @@ use Illuminate\Support\Collection; * * @method static AudioFactory factory(...$parameters) */ -class Audio extends BaseModel implements HasAggregateViews, SoftDeletable, Streamable, Viewable +class Audio extends BaseModel implements HasAggregateViews, SoftDeletable, Streamable { use AggregatesView; use HasFactory; - use InteractsWithViews; use Reportable; use SoftDeletes; @@ -54,7 +51,6 @@ class Audio extends BaseModel implements HasAggregateViews, SoftDeletable, Strea final public const ATTRIBUTE_SIZE = 'size'; final public const RELATION_VIDEOS = 'videos'; - final public const RELATION_VIEWS = 'views'; /** * The attributes that are mass assignable. diff --git a/app/Models/Wiki/Video.php b/app/Models/Wiki/Video.php index ae00fd33a..056b72fe5 100644 --- a/app/Models/Wiki/Video.php +++ b/app/Models/Wiki/Video.php @@ -29,8 +29,6 @@ use App\Models\List\Playlist\PlaylistTrack; use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; use App\Models\Wiki\Video\VideoScript; use App\Pivots\Wiki\AnimeThemeEntryVideo; -use CyrildeWit\EloquentViewable\Contracts\Viewable; -use CyrildeWit\EloquentViewable\InteractsWithViews; use Database\Factories\Wiki\VideoFactory; use Elastic\ScoutDriverPlus\Searchable; use Illuminate\Database\Eloquent\Builder; @@ -65,13 +63,12 @@ use Illuminate\Support\Collection; * * @method static VideoFactory factory(...$parameters) */ -class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, Likeable, SoftDeletable, Streamable, Viewable +class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, Likeable, SoftDeletable, Streamable { use AggregatesLike; use AggregatesView; use HasFactory; use InteractsWithLikes; - use InteractsWithViews; use Reportable; use Searchable; use SoftDeletes; @@ -104,7 +101,6 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L final public const RELATION_SCRIPT = 'videoscript'; final public const RELATION_SONG = 'animethemeentries.animetheme.song'; final public const RELATION_TRACKS = 'tracks'; - final public const RELATION_VIEWS = 'views'; /** * The attributes that are mass assignable. diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 099effc90..baabff12e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace App\Providers; -use App\Http\Middleware\Models\RecordView; use App\Models\Document\Page; use App\Models\Wiki\Anime; use App\Models\Wiki\Anime\AnimeSynonym; @@ -124,9 +123,4 @@ class AppServiceProvider extends ServiceProvider 'artistsong' => ArtistSong::class, ]); } - - public function register(): void - { - $this->app->singleton(RecordView::class); - } } diff --git a/app/Providers/ViewableServiceProvider.php b/app/Providers/ViewableServiceProvider.php deleted file mode 100644 index 131e9bf32..000000000 --- a/app/Providers/ViewableServiceProvider.php +++ /dev/null @@ -1,19 +0,0 @@ -app->bind(ViewContract::class, View::class); - } -} diff --git a/composer.json b/composer.json index 4b7c82f0f..3b28f0ace 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ "babenkoivan/elastic-migrations": "^3.4.1", "babenkoivan/elastic-scout-driver-plus": "^4.8", "bepsvpt/secure-headers": "^7.5", - "cyrildewit/eloquent-viewable": "^7.0.6", "fakerphp/faker": "^1.24.1", "filament/filament": "^4.0.4", "flowframe/laravel-trend": ">=0.4", diff --git a/composer.lock b/composer.lock index ad169c56e..7bad166a6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "022b4fe4f9b0037a49aacb05ded35c30", + "content-hash": "20c6df267bc580b71b6ff0b7b1762ca3", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -1232,90 +1232,6 @@ ], "time": "2024-07-16T11:13:48+00:00" }, - { - "name": "cyrildewit/eloquent-viewable", - "version": "v7.0.6", - "source": { - "type": "git", - "url": "https://github.com/cyrildewit/eloquent-viewable.git", - "reference": "c4153d03f8c1fd7bd9397844e94c4cefc01b2cf2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cyrildewit/eloquent-viewable/zipball/c4153d03f8c1fd7bd9397844e94c4cefc01b2cf2", - "reference": "c4153d03f8c1fd7bd9397844e94c4cefc01b2cf2", - "shasum": "" - }, - "require": { - "illuminate/cache": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "illuminate/contracts": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "illuminate/cookie": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "illuminate/database": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "illuminate/http": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "illuminate/support": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "jaybizzle/crawler-detect": "^1.0", - "nesbot/carbon": "^2.0|^3.0", - "php": "^7.4|^8.0" - }, - "require-dev": { - "illuminate/config": "^6.0|^7.0|^8.74|^9.0|^10.0|^11.0|^12.0", - "laravel/legacy-factories": "^1.1|^1.3", - "mockery/mockery": "^1.2.4", - "orchestra/testbench": "^4.9.1|^5.9.1|^6.6.1|^7.0.0|^8.0.0", - "phpunit/phpunit": "^9.6.0|^10.0||^11.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "CyrildeWit\\EloquentViewable\\EloquentViewableServiceProvider" - ] - } - }, - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "CyrildeWit\\EloquentViewable\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Cyril de Wit", - "email": "info@cyrildewit.nl", - "homepage": "http://cyrildewit.nl", - "role": "Developer" - } - ], - "description": "Laravel package that allows you to associate views with Eloquent models", - "homepage": "https://github.com/cyrildewit/eloquent-viewable", - "keywords": [ - "counter", - "eloquent", - "hits", - "laravel", - "viewable", - "views", - "visitable", - "visits" - ], - "support": { - "issues": "https://github.com/cyrildewit/eloquent-viewable/issues", - "source": "https://github.com/cyrildewit/eloquent-viewable/tree/v7.0.6" - }, - "funding": [ - { - "url": "https://github.com/cyrildewit", - "type": "github" - } - ], - "time": "2025-04-02T23:09:30+00:00" - }, { "name": "danharrin/date-format-converter", "version": "v0.3.1", @@ -3316,58 +3232,6 @@ }, "time": "2025-03-17T16:59:46+00:00" }, - { - "name": "jaybizzle/crawler-detect", - "version": "v1.3.5", - "source": { - "type": "git", - "url": "https://github.com/JayBizzle/Crawler-Detect.git", - "reference": "fbf1a3e81d61b088e7af723fb3c7a4ee92ac7e34" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/fbf1a3e81d61b088e7af723fb3c7a4ee92ac7e34", - "reference": "fbf1a3e81d61b088e7af723fb3c7a4ee92ac7e34", - "shasum": "" - }, - "require": { - "php": ">=7.1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8|^5.5|^6.5|^9.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Jaybizzle\\CrawlerDetect\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mark Beech", - "email": "m@rkbee.ch", - "role": "Developer" - } - ], - "description": "CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent", - "homepage": "https://github.com/JayBizzle/Crawler-Detect/", - "keywords": [ - "crawler", - "crawler detect", - "crawler detector", - "crawlerdetect", - "php crawler detect" - ], - "support": { - "issues": "https://github.com/JayBizzle/Crawler-Detect/issues", - "source": "https://github.com/JayBizzle/Crawler-Detect/tree/v1.3.5" - }, - "time": "2025-06-11T17:58:05+00:00" - }, { "name": "kirschbaum-development/eloquent-power-joins", "version": "4.2.8", diff --git a/config/app.php b/config/app.php index de991d5c0..9b5749d74 100644 --- a/config/app.php +++ b/config/app.php @@ -228,7 +228,6 @@ return [ App\Providers\HorizonServiceProvider::class, App\Providers\PulseServiceProvider::class, App\Providers\RouteServiceProvider::class, - App\Providers\ViewableServiceProvider::class, ])->toArray(), /* diff --git a/config/eloquent-viewable.php b/config/eloquent-viewable.php deleted file mode 100644 index 4742c53ed..000000000 --- a/config/eloquent-viewable.php +++ /dev/null @@ -1,109 +0,0 @@ - [ - - /* - * Here you can configure the default `View` model. - */ - 'view' => [ - - 'table_name' => 'views', - 'connection' => env('DB_CONNECTION', 'mysql_prod'), - - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Cache Configuration - |-------------------------------------------------------------------------- - */ - 'cache' => [ - - /* - * Everthing will be stored under the following key. - */ - 'key' => 'cyrildewit.eloquent-viewable.cache', - - /* - * Here you may define the cache store that should be used. - */ - 'store' => env('CACHE_DRIVER', 'file'), - - ], - - /* - |-------------------------------------------------------------------------- - | Cooldown Configuration - |-------------------------------------------------------------------------- - */ - 'cooldown' => [ - - /* - * Everthing will be stored under the following key in the session. - */ - 'key' => 'cyrildewit.eloquent-viewable.cooldowns', - - ], - - /* - |-------------------------------------------------------------------------- - | Ignore Bots - |-------------------------------------------------------------------------- - | - | If you want to ignore bots, you can specify that here. The default - | service that determines if a visitor is a crawler is a package - | by JayBizzle called CrawlerDetect. - | - */ - 'ignore_bots' => true, - - /* - |-------------------------------------------------------------------------- - | Do Not Track Header - |-------------------------------------------------------------------------- - | - | If you want to honor the DNT header, you can specify that here. We won't - | record views from visitors with the Do Not Track header. - | - */ - 'honor_dnt' => false, - - /* - |-------------------------------------------------------------------------- - | Cookies - |-------------------------------------------------------------------------- - | - | This package binds visitors to views using a cookie. If you want to - | give this cookie a custom name, you can specify that here. - | - */ - - 'visitor_cookie_key' => 'eloquent_viewable', - - /* - |-------------------------------------------------------------------------- - | Ignore IP Addresses - |-------------------------------------------------------------------------- - | - | Ignore views of the following IP addresses. - | - */ - - 'ignored_ip_addresses' => [ - - // '127.0.0.1', - - ], - -]; diff --git a/database/migrations/2020_12_08_034959_create_views_table.php b/database/migrations/2020_12_08_034959_create_views_table.php deleted file mode 100644 index decbb56d1..000000000 --- a/database/migrations/2020_12_08_034959_create_views_table.php +++ /dev/null @@ -1,65 +0,0 @@ -schema = Schema::connection( - config('eloquent-viewable.models.view.connection') - ); - - $this->table = config('eloquent-viewable.models.view.table_name'); - } - - /** - * Run the migrations. - */ - public function up(): void - { - if (! $this->schema->hasTable($this->table)) { - $this->schema->create($this->table, function (Blueprint $table) { - $table->bigIncrements('id'); - $table->morphs('viewable'); - $table->text('visitor')->nullable(); - $table->string('collection')->nullable(); - $table->timestamp('viewed_at')->useCurrent(); - - $table->unsignedBigInteger('user_id')->nullable(); - $table->foreign('user_id')->references(User::ATTRIBUTE_ID)->on(User::TABLE)->nullOnDelete(); - - $table->string('referer', 1000)->nullable(); - $table->string('user_agent', 1000)->nullable(); - }); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists($this->table); - } -}; diff --git a/database/seeders/Admin/Feature/FeatureSeeder.php b/database/seeders/Admin/Feature/FeatureSeeder.php index 8c6084643..52d898515 100644 --- a/database/seeders/Admin/Feature/FeatureSeeder.php +++ b/database/seeders/Admin/Feature/FeatureSeeder.php @@ -31,7 +31,6 @@ class FeatureSeeder extends Seeder Feature::deactivate(AllowVideoStreams::class); Feature::deactivate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); - Feature::deactivate(FeatureConstants::ALLOW_VIEW_RECORDING); Feature::activate(FeatureConstants::AUDIO_BITRATE_RESTRICTION); Feature::activate(FeatureConstants::ENABLED_ONLY_ON_LOCALHOST); Feature::deactivate(FeatureConstants::IGNORE_ALL_FILE_VALIDATIONS); diff --git a/routes/audio.php b/routes/audio.php index 581524566..087d9f511 100644 --- a/routes/audio.php +++ b/routes/audio.php @@ -15,4 +15,4 @@ $isAudioStreamingAllowed = Str::of(EnsureFeaturesAreActive::class) Route::get('/{audio}', [AudioController::class, 'show']) ->name('audio.show') - ->middleware([$isAudioStreamingAllowed, 'record_view:audio']); + ->middleware([$isAudioStreamingAllowed]); diff --git a/routes/video.php b/routes/video.php index 84240fc0a..e66d57e20 100644 --- a/routes/video.php +++ b/routes/video.php @@ -15,4 +15,4 @@ $isVideoStreamingAllowed = Str::of(EnsureFeaturesAreActive::class) Route::get('/{video}', [VideoController::class, 'show']) ->name('video.show') - ->middleware([$isVideoStreamingAllowed, 'record_view:video', 'throttle:video']); + ->middleware([$isVideoStreamingAllowed, 'throttle:video']); diff --git a/tests/Feature/Http/Wiki/Audio/AudioTest.php b/tests/Feature/Http/Wiki/Audio/AudioTest.php index aa601c951..ebf335b23 100644 --- a/tests/Feature/Http/Wiki/Audio/AudioTest.php +++ b/tests/Feature/Http/Wiki/Audio/AudioTest.php @@ -3,14 +3,12 @@ declare(strict_types=1); use App\Constants\Config\AudioConstants; -use App\Constants\FeatureConstants; use App\Enums\Auth\SpecialPermission; use App\Enums\Http\StreamingMethod; use App\Features\AllowAudioStreams; use App\Models\Auth\User; use App\Models\Wiki\Audio; use Illuminate\Support\Arr; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Storage; use Laravel\Pennant\Feature; @@ -66,47 +64,6 @@ test('cannot stream soft deleted audio', function () { $response->assertNotFound(); }); -test('view recording not allowed', function () { - Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); - - Feature::activate(AllowAudioStreams::class); - Feature::deactivate(FeatureConstants::ALLOW_VIEW_RECORDING); - - $audio = Audio::factory()->createOne(); - - get(route('audio.show', ['audio' => $audio])); - - $this->assertEquals(0, $audio->views()->count()); -}); - -test('view recording is allowed', function () { - Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); - - Feature::activate(AllowAudioStreams::class); - Feature::activate(FeatureConstants::ALLOW_VIEW_RECORDING); - - $audio = Audio::factory()->createOne(); - - get(route('audio.show', ['audio' => $audio])); - - $this->assertEquals(1, $audio->views()->count()); -}); - -test('view recording cooldown', function () { - Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); - - Feature::activate(AllowAudioStreams::class); - Feature::activate(FeatureConstants::ALLOW_VIEW_RECORDING); - - $audio = Audio::factory()->createOne(); - - Collection::times(fake()->randomDigitNotNull(), function () use ($audio) { - get(route('audio.show', ['audio' => $audio])); - }); - - $this->assertEquals(1, $audio->views()->count()); -}); - test('invalid streaming method error', function () { Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); diff --git a/tests/Feature/Http/Wiki/Video/VideoTest.php b/tests/Feature/Http/Wiki/Video/VideoTest.php index 65fedbd29..835ce44c0 100644 --- a/tests/Feature/Http/Wiki/Video/VideoTest.php +++ b/tests/Feature/Http/Wiki/Video/VideoTest.php @@ -50,19 +50,6 @@ test('cannot stream soft deleted video', function () { $response->assertNotFound(); }); -test('view recording not allowed', function () { - Storage::fake(Config::get(VideoConstants::DEFAULT_DISK_QUALIFIED)); - - Feature::activate(AllowVideoStreams::class); - Feature::deactivate(FeatureConstants::ALLOW_VIEW_RECORDING); - - $video = Video::factory()->createOne(); - - get(route('video.show', ['video' => $video])); - - $this->assertEquals(0, $video->views()->count()); -}); - test('video streaming permitted for bypass', function () { Storage::fake(Config::get(VideoConstants::DEFAULT_DISK_QUALIFIED)); @@ -83,34 +70,6 @@ test('video streaming permitted for bypass', function () { $response->assertSuccessful(); }); -test('view recording is allowed', function () { - Storage::fake(Config::get(VideoConstants::DEFAULT_DISK_QUALIFIED)); - - Feature::activate(AllowVideoStreams::class); - Feature::activate(FeatureConstants::ALLOW_VIEW_RECORDING); - - $video = Video::factory()->createOne(); - - get(route('video.show', ['video' => $video])); - - $this->assertEquals(1, $video->views()->count()); -}); - -test('view recording cooldown', function () { - Storage::fake(Config::get(VideoConstants::DEFAULT_DISK_QUALIFIED)); - - Feature::activate(AllowVideoStreams::class); - Feature::activate(FeatureConstants::ALLOW_VIEW_RECORDING); - - $video = Video::factory()->createOne(); - - Collection::times(fake()->randomDigitNotNull(), function () use ($video) { - get(route('video.show', ['video' => $video])); - }); - - $this->assertEquals(1, $video->views()->count()); -}); - test('invalid streaming method error', function () { Storage::fake(Config::get(VideoConstants::DEFAULT_DISK_QUALIFIED)); diff --git a/tests/Unit/Models/Wiki/AudioTest.php b/tests/Unit/Models/Wiki/AudioTest.php index bcd6bd812..f870d1ab7 100644 --- a/tests/Unit/Models/Wiki/AudioTest.php +++ b/tests/Unit/Models/Wiki/AudioTest.php @@ -6,9 +6,7 @@ use App\Constants\Config\AudioConstants; use App\Events\Wiki\Audio\AudioForceDeleting; use App\Models\Wiki\Audio; use App\Models\Wiki\Video; -use CyrildeWit\EloquentViewable\View; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Http\Testing\File; use Illuminate\Support\Facades\Config; @@ -41,16 +39,6 @@ test('videos', function () { $this->assertInstanceOf(Video::class, $audio->videos()->first()); }); -test('views', function () { - $audio = Audio::factory()->createOne(); - - views($audio)->record(); - - $this->assertInstanceOf(MorphMany::class, $audio->views()); - $this->assertEquals(1, $audio->views()->count()); - $this->assertInstanceOf(View::class, $audio->views()->first()); -}); - test('audio storage deletion', function () { $fs = Storage::fake(Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.ogg', fake()->randomDigitNotNull()); diff --git a/tests/Unit/Models/Wiki/VideoTest.php b/tests/Unit/Models/Wiki/VideoTest.php index 9c0418541..aae4c0222 100644 --- a/tests/Unit/Models/Wiki/VideoTest.php +++ b/tests/Unit/Models/Wiki/VideoTest.php @@ -16,12 +16,10 @@ use App\Models\Wiki\Audio; use App\Models\Wiki\Video; use App\Models\Wiki\Video\VideoScript; use App\Pivots\Wiki\AnimeThemeEntryVideo; -use CyrildeWit\EloquentViewable\View; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; -use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Http\Testing\File; use Illuminate\Support\Arr; @@ -71,16 +69,6 @@ test('has subtitle', function () { $this->assertIsString($video->getSubtitle()); }); -test('views', function () { - $video = Video::factory()->createOne(); - - views($video)->record(); - - $this->assertInstanceOf(MorphMany::class, $video->views()); - $this->assertEquals(1, $video->views()->count()); - $this->assertInstanceOf(View::class, $video->views()->first()); -}); - test('appends tags', function () { $video = Video::factory()->createOne();