From 0e41771f4c24ddcd2607646b8f0730552fa9c872 Mon Sep 17 00:00:00 2001 From: Kyrch Date: Sun, 26 Apr 2026 14:37:24 -0300 Subject: [PATCH] clean: remove discord thread features (#1191) --- app/Actions/Discord/DiscordThreadAction.php | 72 -------- .../DiscordVideoNotificationAction.php | 44 ++--- .../Storage/Admin/Dump/DumpDiscordAction.php | 44 ----- .../Storage/Admin/DiscordDumpCommand.php | 36 ---- app/Console/Kernel.php | 7 - app/Constants/Config/ServiceConstants.php | 1 - .../DiscordThread/DiscordThreadDeleted.php | 13 -- .../DiscordThread/DiscordThreadUpdated.php | 20 -- app/Events/Wiki/Anime/AnimeDeleting.php | 3 - .../Models/Wiki/Anime/DiscordThreadAction.php | 54 ------ .../VideoDiscordNotificationBulkAction.php | 3 +- .../Pages/ListDiscordThreads.php | 13 -- .../DiscordThread/Pages/ViewDiscordThread.php | 13 -- .../Discord/DiscordThreadResource.php | 171 ------------------ app/Filament/Resources/Wiki/AnimeResource.php | 3 - app/Models/Discord/DiscordThread.php | 95 ---------- app/Models/Wiki/Anime.php | 11 -- .../Discord/DiscordThreadObserver.php | 32 ---- app/Policies/Discord/DiscordThreadPolicy.php | 9 - .../Discord/DiscordThreadFactory.php | 32 ---- ...31_052841_create_discord_threads_table.php | 27 --- .../Auth/Permission/PermissionSeeder.php | 4 - database/seeders/Auth/Role/AdminSeeder.php | 4 - .../Auth/Role/ContentModeratorRoleSeeder.php | 4 - .../Auth/Role/ContributorRoleSeeder.php | 4 - .../seeders/Auth/Role/DeveloperRoleSeeder.php | 4 - .../seeders/Auth/Role/EncoderRoleSeeder.php | 4 - .../Auth/Role/PanelViewerRoleSeeder.php | 4 - .../seeders/Auth/Role/PatronRoleSeeder.php | 4 - lang/en/filament.php | 21 --- .../Storage/Admin/DiscordDumpTest.php | 35 ---- .../Resources/Discord/DiscordThreadTest.php | 116 ------------ .../Jobs/Discord/DiscordThreadTest.php | 49 ----- .../Unit/Models/Discord/DiscordThreadTest.php | 35 ---- 34 files changed, 15 insertions(+), 976 deletions(-) delete mode 100644 app/Actions/Discord/DiscordThreadAction.php delete mode 100644 app/Actions/Storage/Admin/Dump/DumpDiscordAction.php delete mode 100644 app/Console/Commands/Storage/Admin/DiscordDumpCommand.php delete mode 100644 app/Events/Discord/DiscordThread/DiscordThreadDeleted.php delete mode 100644 app/Events/Discord/DiscordThread/DiscordThreadUpdated.php delete mode 100644 app/Filament/Actions/Models/Wiki/Anime/DiscordThreadAction.php delete mode 100644 app/Filament/Resources/Discord/DiscordThread/Pages/ListDiscordThreads.php delete mode 100644 app/Filament/Resources/Discord/DiscordThread/Pages/ViewDiscordThread.php delete mode 100644 app/Filament/Resources/Discord/DiscordThreadResource.php delete mode 100644 app/Models/Discord/DiscordThread.php delete mode 100644 app/Observers/Discord/DiscordThreadObserver.php delete mode 100644 app/Policies/Discord/DiscordThreadPolicy.php delete mode 100644 database/factories/Discord/DiscordThreadFactory.php delete mode 100644 database/migrations/2024_05_31_052841_create_discord_threads_table.php delete mode 100644 tests/Feature/Console/Commands/Storage/Admin/DiscordDumpTest.php delete mode 100644 tests/Feature/Filament/Resources/Discord/DiscordThreadTest.php delete mode 100644 tests/Feature/Jobs/Discord/DiscordThreadTest.php delete mode 100644 tests/Unit/Models/Discord/DiscordThreadTest.php diff --git a/app/Actions/Discord/DiscordThreadAction.php b/app/Actions/Discord/DiscordThreadAction.php deleted file mode 100644 index efb51812f..000000000 --- a/app/Actions/Discord/DiscordThreadAction.php +++ /dev/null @@ -1,72 +0,0 @@ - Config::get('services.discord.api_key')]) - ->baseUrl(Config::get('services.discord.api_url')); - } - - /** - * @param array $fields - * - * @throws Exception - */ - public function handle(Anime $anime, array $fields): ActionResult - { - try { - $response = static::getHttp() - ->acceptJson() - ->post('/thread', ['name' => Arr::get($fields, 'name'), 'slug' => $anime->slug]) - ->throw() - ->json(); - - if (Arr::has($response, 'id')) { - DiscordThread::query()->create([ - DiscordThread::ATTRIBUTE_NAME => Arr::get($response, 'name'), - DiscordThread::ATTRIBUTE_ID => intval(Arr::get($response, 'id')), - DiscordThread::ATTRIBUTE_ANIME => $anime->getKey(), - ]); - } - } catch (Exception $e) { - Log::error($e->getMessage()); - - throw $e; - } - - return new ActionResult(ActionStatus::PASSED); - } - - /** - * Get the thread by ID. - * - * @return array - */ - public function get(string $id): array - { - return static::getHttp() - ->acceptJson() - ->get('/thread', ['id' => $id]) - ->throw() - ->json(); - } -} diff --git a/app/Actions/Discord/DiscordVideoNotificationAction.php b/app/Actions/Discord/DiscordVideoNotificationAction.php index ad0bd5b57..20c68c3af 100644 --- a/app/Actions/Discord/DiscordVideoNotificationAction.php +++ b/app/Actions/Discord/DiscordVideoNotificationAction.php @@ -8,12 +8,23 @@ use App\Actions\ActionResult; use App\Enums\Actions\ActionStatus; use App\Enums\Actions\Models\Wiki\Video\DiscordNotificationType; use App\Models\Wiki\Video; +use Illuminate\Http\Client\PendingRequest; use Illuminate\Support\Arr; use Illuminate\Support\Collection; -use Illuminate\Support\Str; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Http; class DiscordVideoNotificationAction { + /** + * Get the HTTP client for Discord API. + */ + public static function getHttp(): PendingRequest + { + return Http::withHeaders(['x-api-key' => Config::get('services.discord.api_key')]) + ->baseUrl(Config::get('services.discord.api_url')); + } + /** * @param Collection $videos * @param array $fields @@ -22,37 +33,10 @@ class DiscordVideoNotificationAction { $type = Arr::get($fields, DiscordNotificationType::getFieldKey()); - $newVideos = []; - - foreach ($videos as $video) { - $video - ->load([ - 'animethemeentries.animetheme.anime.discordthread', - ]); - - $anime = $video->animethemeentries->first()->animetheme->anime; - - if ($anime->discordthread === null) { - if (Str::length($anime->name) >= 100) { - $anime->name = Str::limit($anime->name, 96, '...'); - } - - $threadAction = new DiscordThreadAction(); - - $threadAction->handle($anime, ['name' => $anime->getName()]); - $anime->load('discordthread'); - } - - $newVideos[] = [ - 'threadId' => $anime->discordthread->getKey(), - 'videoId' => $video->getKey(), - ]; - } - - DiscordThreadAction::getHttp() + static::getHttp() ->post('/notification', [ 'type' => $type->value, - 'videos' => $newVideos, + 'videos' => $videos->map(fn (Video $video): array => ['videoId' => $video->getKey()])->toArray(), ]) ->throw(); diff --git a/app/Actions/Storage/Admin/Dump/DumpDiscordAction.php b/app/Actions/Storage/Admin/Dump/DumpDiscordAction.php deleted file mode 100644 index 72d59fb9e..000000000 --- a/app/Actions/Storage/Admin/Dump/DumpDiscordAction.php +++ /dev/null @@ -1,44 +0,0 @@ -path('')) - ->append(DumpDiscordAction::FILENAME_PREFIX) - ->append(strval(Date::now()->valueOf())) - ->append('.sql') - ->__toString(); - } -} diff --git a/app/Console/Commands/Storage/Admin/DiscordDumpCommand.php b/app/Console/Commands/Storage/Admin/DiscordDumpCommand.php deleted file mode 100644 index 296f1a097..000000000 --- a/app/Console/Commands/Storage/Admin/DiscordDumpCommand.php +++ /dev/null @@ -1,36 +0,0 @@ -options()); - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 37a19c6a6..0df76ced1 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -9,7 +9,6 @@ use App\Console\Commands\Repositories\Storage\Admin\DumpReconcileCommand; use App\Console\Commands\Storage\Admin\AdminDumpCommand; use App\Console\Commands\Storage\Admin\AuthDumpCommand; use App\Console\Commands\Storage\Admin\ContentDumpCommand; -use App\Console\Commands\Storage\Admin\DiscordDumpCommand; use App\Console\Commands\Storage\Admin\DocumentDumpCommand; use App\Console\Commands\Storage\Admin\DumpPruneCommand; use App\Console\Commands\Storage\Admin\ListDumpCommand; @@ -61,12 +60,6 @@ class Kernel extends ConsoleKernel ->storeOutput() ->weeklyOn(Schedule::MONDAY); - $schedule->command(DiscordDumpCommand::class) - ->withoutOverlapping() - ->runInBackground() - ->storeOutput() - ->weeklyOn(Schedule::MONDAY); - $schedule->command(DocumentDumpCommand::class) ->withoutOverlapping() ->runInBackground() diff --git a/app/Constants/Config/ServiceConstants.php b/app/Constants/Config/ServiceConstants.php index e3db312c0..9e58afabc 100644 --- a/app/Constants/Config/ServiceConstants.php +++ b/app/Constants/Config/ServiceConstants.php @@ -8,7 +8,6 @@ class ServiceConstants { final public const string ADMIN_DISCORD_CHANNEL_QUALIFIED = 'services.discord.admin_discord_channel'; final public const string DB_UPDATES_DISCORD_CHANNEL_QUALIFIED = 'services.discord.db_updates_discord_channel'; - final public const string SUBMISSIONS_DISCORD_CHANNEL_QUALIFIED = 'services.discord.submissions_discord_channel'; final public const string OPENAI_BEARER_TOKEN = 'services.openai.token'; diff --git a/app/Events/Discord/DiscordThread/DiscordThreadDeleted.php b/app/Events/Discord/DiscordThread/DiscordThreadDeleted.php deleted file mode 100644 index 41db84f7b..000000000 --- a/app/Events/Discord/DiscordThread/DiscordThreadDeleted.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -class DiscordThreadDeleted extends AdminDeletedEvent {} diff --git a/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php b/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php deleted file mode 100644 index 808577943..000000000 --- a/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class DiscordThreadUpdated extends AdminUpdatedEvent -{ - public function __construct(DiscordThread $thread) - { - parent::__construct($thread); - $this->initializeEmbedFields($thread); - } -} diff --git a/app/Events/Wiki/Anime/AnimeDeleting.php b/app/Events/Wiki/Anime/AnimeDeleting.php index 4c955de9f..f56a8e9d1 100644 --- a/app/Events/Wiki/Anime/AnimeDeleting.php +++ b/app/Events/Wiki/Anime/AnimeDeleting.php @@ -20,13 +20,10 @@ class AnimeDeleting extends BaseEvent implements CascadesDeletesEvent public function cascadeDeletes(): void { $anime = $this->getModel()->load([ - 'discordthread', Anime::RELATION_SYNONYMS, Anime::RELATION_VIDEOS, ]); - $anime->discordthread?->delete(); - $anime->synonyms->each(function (Synonym $synonym): void { Synonym::withoutEvents(function () use ($synonym): void { $synonym->unsearchable(); diff --git a/app/Filament/Actions/Models/Wiki/Anime/DiscordThreadAction.php b/app/Filament/Actions/Models/Wiki/Anime/DiscordThreadAction.php deleted file mode 100644 index 21a679b4b..000000000 --- a/app/Filament/Actions/Models/Wiki/Anime/DiscordThreadAction.php +++ /dev/null @@ -1,54 +0,0 @@ -label(__('filament.actions.anime.discord_thread.name')); - $this->icon(Heroicon::OutlinedChatBubbleLeftRight); - - $this->visible(Gate::allows('create', DiscordThread::class)); - - $this->fillForm(fn (Anime $record): array => ['name' => $record->getName()]); - - $this->action(function (Anime $record, array $data): void { - $result = new DiscordThreadActionAction()->handle($record, $data); - - if ($result->hasFailed()) { - $this->failedLog($result->getMessage()); - } - }); - } - - public function getSchema(Schema $schema): Schema - { - return $schema - ->components([ - TextInput::make('name') - ->label(__('filament.actions.discord.thread.name')) - ->helperText(__('filament.actions.discord.thread.help')) - ->required() - ->maxlength(100), - ]); - } -} diff --git a/app/Filament/BulkActions/Models/Wiki/Video/VideoDiscordNotificationBulkAction.php b/app/Filament/BulkActions/Models/Wiki/Video/VideoDiscordNotificationBulkAction.php index 6ebee8a57..a860e9a23 100644 --- a/app/Filament/BulkActions/Models/Wiki/Video/VideoDiscordNotificationBulkAction.php +++ b/app/Filament/BulkActions/Models/Wiki/Video/VideoDiscordNotificationBulkAction.php @@ -8,7 +8,6 @@ use App\Actions\Discord\DiscordVideoNotificationAction as DiscordVideoNotificati use App\Enums\Actions\Models\Wiki\Video\DiscordNotificationType; use App\Filament\BulkActions\BaseBulkAction; use App\Filament\Components\Fields\Select; -use App\Models\Discord\DiscordThread; use App\Models\Wiki\Video; use Filament\Schemas\Schema; use Filament\Support\Enums\Width; @@ -32,7 +31,7 @@ class VideoDiscordNotificationBulkAction extends BaseBulkAction $this->label(__('filament.bulk_actions.discord.notification.name')); $this->icon(Heroicon::OutlinedBell); - $this->visible(Gate::allows('create', DiscordThread::class)); + $this->visible(Gate::allows('create', Video::class)); } /** diff --git a/app/Filament/Resources/Discord/DiscordThread/Pages/ListDiscordThreads.php b/app/Filament/Resources/Discord/DiscordThread/Pages/ListDiscordThreads.php deleted file mode 100644 index 7bbc11a26..000000000 --- a/app/Filament/Resources/Discord/DiscordThread/Pages/ListDiscordThreads.php +++ /dev/null @@ -1,13 +0,0 @@ -|null - */ - protected static ?string $model = DiscordThread::class; - - public static function getModelLabel(): string - { - return __('filament.resources.singularLabel.discord_thread'); - } - - public static function getPluralModelLabel(): string - { - return __('filament.resources.label.discord_threads'); - } - - public static function getNavigationGroup(): NavigationGroup - { - return NavigationGroup::DISCORD; - } - - public static function getNavigationIcon(): Heroicon - { - return Heroicon::OutlinedChatBubbleLeftRight; - } - - public static function getRecordTitleAttribute(): string - { - return DiscordThread::ATTRIBUTE_NAME; - } - - public static function getRecordSlug(): string - { - return 'discord-thread'; - } - - public static function getEloquentQuery(): Builder - { - $query = parent::getEloquentQuery(); - - // Necessary to prevent lazy loading when loading related resources - return $query->with([DiscordThread::RELATION_ANIME]); - } - - public static function form(Schema $schema): Schema - { - return $schema - ->components([ - TextInput::make(DiscordThread::ATTRIBUTE_ID) - ->label(__('filament.fields.discord_thread.id.name')) - ->helperText(__('filament.fields.discord_thread.id.help')) - ->disabledOn(['edit']) - ->formatStateUsing(fn ($state): string => strval($state)) - ->required() - ->live() - ->afterStateUpdated(fn (Set $set, string $state): mixed => $set(DiscordThread::ATTRIBUTE_NAME, Arr::get(new DiscordThreadAction()->get($state), 'thread.name'))), - - TextInput::make(DiscordThread::ATTRIBUTE_NAME) - ->label(__('filament.fields.discord_thread.name.name')) - ->helperText(__('filament.fields.discord_thread.name.help')) - ->required(), - - BelongsTo::make(DiscordThread::ATTRIBUTE_ANIME) - ->resource(AnimeResource::class) - ->required(), - ]); - } - - public static function table(Table $table): Table - { - return parent::table($table) - ->columns([ - TextColumn::make(DiscordThread::ATTRIBUTE_ID) - ->label(__('filament.fields.discord_thread.id.name')), - - TextColumn::make(DiscordThread::ATTRIBUTE_NAME) - ->label(__('filament.fields.discord_thread.name.name')) - ->copyableWithMessage() - ->searchable(), - - BelongsToColumn::make(DiscordThread::RELATION_ANIME, AnimeResource::class), - ]) - ->defaultSort(BaseModel::CREATED_AT, 'desc'); - } - - public static function infolist(Schema $schema): Schema - { - return $schema - ->components([ - Section::make(static::getRecordTitle($schema->getRecord())) - ->schema([ - TextEntry::make(DiscordThread::ATTRIBUTE_ID) - ->label(__('filament.fields.discord_thread.id.name')), - - TextEntry::make(DiscordThread::ATTRIBUTE_NAME) - ->label(__('filament.fields.discord_thread.name.name')), - - BelongsToEntry::make(DiscordThread::RELATION_ANIME, AnimeResource::class), - ]) - ->columns(3), - ]); - } - - /** - * @return array> - */ - public static function getRelations(): array - { - return [ - RelationGroup::make(static::getModelLabel(), [ - ...parent::getBaseRelations(), - ]), - ]; - } - - /** - * @return \Filament\Tables\Filters\BaseFilter[] - */ - public static function getFilters(): array - { - return [ - DateFilter::make(BaseModel::ATTRIBUTE_CREATED_AT) - ->label(__('filament.fields.base.created_at')), - ]; - } - - /** - * @return array - */ - public static function getPages(): array - { - return [ - 'index' => ListDiscordThreads::route('/'), - 'view' => ViewDiscordThread::route('/{record:thread_id}'), - ]; - } -} diff --git a/app/Filament/Resources/Wiki/AnimeResource.php b/app/Filament/Resources/Wiki/AnimeResource.php index 22cc65d1e..ffc6fcb1e 100644 --- a/app/Filament/Resources/Wiki/AnimeResource.php +++ b/app/Filament/Resources/Wiki/AnimeResource.php @@ -10,7 +10,6 @@ use App\Enums\Models\Wiki\AnimeSeason; use App\Enums\Models\Wiki\ResourceSite; use App\Filament\Actions\Models\Wiki\Anime\AttachAnimeResourceAction; use App\Filament\Actions\Models\Wiki\Anime\BackfillAnimeAction; -use App\Filament\Actions\Models\Wiki\Anime\DiscordThreadAction; use App\Filament\Components\Columns\TextColumn; use App\Filament\Components\Fields\Select; use App\Filament\Components\Fields\Slug; @@ -260,8 +259,6 @@ class AnimeResource extends BaseResource ]; return [ - DiscordThreadAction::make(), - BackfillAnimeAction::make(), AttachAnimeResourceAction::make(), diff --git a/app/Models/Discord/DiscordThread.php b/app/Models/Discord/DiscordThread.php deleted file mode 100644 index d9f5b0f50..000000000 --- a/app/Models/Discord/DiscordThread.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - protected $dispatchesEvents = [ - 'deleted' => DiscordThreadDeleted::class, - 'updated' => DiscordThreadUpdated::class, - ]; - - /** - * The attributes that are mass assignable. - * - * @var list - */ - protected $fillable = [ - DiscordThread::ATTRIBUTE_ANIME, - DiscordThread::ATTRIBUTE_ID, - DiscordThread::ATTRIBUTE_NAME, - ]; - - /** - * Get the attributes that should be cast. - * - * @return array - */ - protected function casts(): array - { - return [ - DiscordThread::ATTRIBUTE_ANIME => 'int', - DiscordThread::ATTRIBUTE_NAME => 'string', - ]; - } - - public function getName(): string - { - return $this->name; - } - - public function getSubtitle(): string - { - return $this->anime->getName(); - } - - /** - * @return BelongsTo - */ - public function anime(): BelongsTo - { - return $this->belongsTo(Anime::class, DiscordThread::ATTRIBUTE_ANIME); - } -} diff --git a/app/Models/Wiki/Anime.php b/app/Models/Wiki/Anime.php index 6de151a22..5074d9e37 100644 --- a/app/Models/Wiki/Anime.php +++ b/app/Models/Wiki/Anime.php @@ -21,7 +21,6 @@ use App\Events\Wiki\Anime\AnimeUpdated; use App\Http\Resources\Pivot\Wiki\Resource\AnimeSeriesJsonResource; use App\Http\Resources\Pivot\Wiki\Resource\AnimeStudioJsonResource; use App\Models\BaseModel; -use App\Models\Discord\DiscordThread; use App\Models\List\External\ExternalEntry; use App\Models\Wiki\Anime\AnimeSynonym; use App\Models\Wiki\Anime\AnimeTheme; @@ -41,7 +40,6 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; 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\Database\Eloquent\Relations\MorphToMany; use Illuminate\Support\Collection; @@ -53,7 +51,6 @@ use RuntimeException; /** * @property int $anime_id * @property Collection $animethemes - * @property DiscordThread|null $discordthread * @property Collection $externalentries * @property AnimeFormat|null $format * @property Collection $images @@ -218,14 +215,6 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has return $this->morphMany(Synonym::class, Synonym::RELATION_SYNONYMABLE); } - /** - * @return HasOne - */ - public function discordthread(): HasOne - { - return $this->hasOne(DiscordThread::class, DiscordThread::ATTRIBUTE_ANIME); - } - /** * @return BelongsToMany */ diff --git a/app/Observers/Discord/DiscordThreadObserver.php b/app/Observers/Discord/DiscordThreadObserver.php deleted file mode 100644 index a1c9464f7..000000000 --- a/app/Observers/Discord/DiscordThreadObserver.php +++ /dev/null @@ -1,32 +0,0 @@ -put('/thread', $thread->toArray()) - ->throw(); - } - - /** - * Handle the DiscordThread "deleted" event. - */ - public function deleted(DiscordThread $thread): void - { - DiscordThreadAction::getHttp() - ->delete('/thread', ['id' => $thread->getKey()]) - ->throw(); - } -} diff --git a/app/Policies/Discord/DiscordThreadPolicy.php b/app/Policies/Discord/DiscordThreadPolicy.php deleted file mode 100644 index 0c3955ce4..000000000 --- a/app/Policies/Discord/DiscordThreadPolicy.php +++ /dev/null @@ -1,9 +0,0 @@ - - */ -#[UseModel(DiscordThread::class)] -class DiscordThreadFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - DiscordThread::ATTRIBUTE_NAME => fake()->words(3, true), - DiscordThread::ATTRIBUTE_ID => fake()->words(3, true), - ]; - } -} diff --git a/database/migrations/2024_05_31_052841_create_discord_threads_table.php b/database/migrations/2024_05_31_052841_create_discord_threads_table.php deleted file mode 100644 index c9844e730..000000000 --- a/database/migrations/2024_05_31_052841_create_discord_threads_table.php +++ /dev/null @@ -1,27 +0,0 @@ -timestamps(6); - $table->string('thread_id')->primary(); - $table->string('name'); - - $table->unsignedBigInteger('anime_id'); - $table->foreign('anime_id')->references('anime_id')->on('anime'); - }); - } - } -}; diff --git a/database/seeders/Auth/Permission/PermissionSeeder.php b/database/seeders/Auth/Permission/PermissionSeeder.php index 0d13d2685..8362db6a7 100644 --- a/database/seeders/Auth/Permission/PermissionSeeder.php +++ b/database/seeders/Auth/Permission/PermissionSeeder.php @@ -16,7 +16,6 @@ use App\Models\Auth\Prohibition; use App\Models\Auth\Role; use App\Models\Auth\Sanction; use App\Models\Auth\User; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -69,9 +68,6 @@ class PermissionSeeder extends Seeder $this->registerResource(Sanction::class, CrudPermission::cases()); $this->registerResource(User::class, $extendedCrudPermissions); - // Discord Resources - $this->registerResource(DiscordThread::class, CrudPermission::cases()); - // List Resources $this->registerResource(ExternalEntry::class, CrudPermission::cases()); $this->registerResource(ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/AdminSeeder.php b/database/seeders/Auth/Role/AdminSeeder.php index ca8a7b2a5..df825c17a 100644 --- a/database/seeders/Auth/Role/AdminSeeder.php +++ b/database/seeders/Auth/Role/AdminSeeder.php @@ -17,7 +17,6 @@ use App\Models\Auth\Prohibition; use App\Models\Auth\Role; use App\Models\Auth\Sanction; use App\Models\Auth\User; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -77,9 +76,6 @@ class AdminSeeder extends RoleSeeder $this->configureResource($role, Sanction::class, CrudPermission::cases()); $this->configureResource($role, User::class, $extendedCrudPermissions); - // Discord Resources - $this->configureResource($role, DiscordThread::class, CrudPermission::cases()); - // List Resources $this->configureResource($role, ExternalEntry::class, CrudPermission::cases()); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/ContentModeratorRoleSeeder.php b/database/seeders/Auth/Role/ContentModeratorRoleSeeder.php index c45a7cbaa..ff4c3fa64 100644 --- a/database/seeders/Auth/Role/ContentModeratorRoleSeeder.php +++ b/database/seeders/Auth/Role/ContentModeratorRoleSeeder.php @@ -9,7 +9,6 @@ use App\Enums\Auth\ExtendedCrudPermission; use App\Enums\Auth\Role as RoleEnum; use App\Enums\Auth\SpecialPermission; use App\Models\Auth\Role; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -54,9 +53,6 @@ class ContentModeratorRoleSeeder extends RoleSeeder ExtendedCrudPermission::cases(), ); - // Discord Resources - $this->configureResource($role, DiscordThread::class, [CrudPermission::VIEW]); - // List Resources $this->configureResource($role, ExternalEntry::class, [CrudPermission::VIEW]); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/ContributorRoleSeeder.php b/database/seeders/Auth/Role/ContributorRoleSeeder.php index feb7f880b..b668b2293 100644 --- a/database/seeders/Auth/Role/ContributorRoleSeeder.php +++ b/database/seeders/Auth/Role/ContributorRoleSeeder.php @@ -8,7 +8,6 @@ use App\Enums\Auth\CrudPermission; use App\Enums\Auth\Role as RoleEnum; use App\Enums\Auth\SpecialPermission; use App\Models\Auth\Role; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -48,9 +47,6 @@ class ContributorRoleSeeder extends RoleSeeder /** @var Role $role */ $role = Role::findOrCreate($roleEnum->value); - // Discord Resources - $this->configureResource($role, DiscordThread::class, [CrudPermission::VIEW]); - // List Resources $this->configureResource($role, ExternalEntry::class, [CrudPermission::VIEW]); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/DeveloperRoleSeeder.php b/database/seeders/Auth/Role/DeveloperRoleSeeder.php index f7cc3121b..1253d195d 100644 --- a/database/seeders/Auth/Role/DeveloperRoleSeeder.php +++ b/database/seeders/Auth/Role/DeveloperRoleSeeder.php @@ -8,7 +8,6 @@ use App\Enums\Auth\CrudPermission; use App\Enums\Auth\Role as RoleEnum; use App\Enums\Auth\SpecialPermission; use App\Models\Auth\Role; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -48,9 +47,6 @@ class DeveloperRoleSeeder extends RoleSeeder /** @var Role $role */ $role = Role::findOrCreate($roleEnum->value); - // Discord Resources - $this->configureResource($role, DiscordThread::class, [CrudPermission::VIEW]); - // List Resources $this->configureResource($role, ExternalEntry::class, [CrudPermission::VIEW]); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/EncoderRoleSeeder.php b/database/seeders/Auth/Role/EncoderRoleSeeder.php index 578420541..bae188e49 100644 --- a/database/seeders/Auth/Role/EncoderRoleSeeder.php +++ b/database/seeders/Auth/Role/EncoderRoleSeeder.php @@ -9,7 +9,6 @@ use App\Enums\Auth\ExtendedCrudPermission; use App\Enums\Auth\Role as RoleEnum; use App\Enums\Auth\SpecialPermission; use App\Models\Auth\Role; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -54,9 +53,6 @@ class EncoderRoleSeeder extends RoleSeeder ExtendedCrudPermission::cases(), ); - // Discord Resources - $this->configureResource($role, DiscordThread::class, [CrudPermission::CREATE, CrudPermission::UPDATE, CrudPermission::VIEW]); - // List Resources $this->configureResource($role, ExternalEntry::class, [CrudPermission::VIEW]); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/PanelViewerRoleSeeder.php b/database/seeders/Auth/Role/PanelViewerRoleSeeder.php index 89318a7a1..f1897fa38 100644 --- a/database/seeders/Auth/Role/PanelViewerRoleSeeder.php +++ b/database/seeders/Auth/Role/PanelViewerRoleSeeder.php @@ -8,7 +8,6 @@ use App\Enums\Auth\CrudPermission; use App\Enums\Auth\Role as RoleEnum; use App\Enums\Auth\SpecialPermission; use App\Models\Auth\Role; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -48,9 +47,6 @@ class PanelViewerRoleSeeder extends RoleSeeder /** @var Role $role */ $role = Role::findOrCreate($roleEnum->value); - // Discord Resources - $this->configureResource($role, DiscordThread::class, [CrudPermission::VIEW]); - // List Resources $this->configureResource($role, ExternalEntry::class, [CrudPermission::VIEW]); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/database/seeders/Auth/Role/PatronRoleSeeder.php b/database/seeders/Auth/Role/PatronRoleSeeder.php index 166d3b5af..f68c5a208 100644 --- a/database/seeders/Auth/Role/PatronRoleSeeder.php +++ b/database/seeders/Auth/Role/PatronRoleSeeder.php @@ -8,7 +8,6 @@ use App\Enums\Auth\CrudPermission; use App\Enums\Auth\Role as RoleEnum; use App\Enums\Auth\SpecialPermission; use App\Models\Auth\Role; -use App\Models\Discord\DiscordThread; use App\Models\Document\Page; use App\Models\List\External\ExternalEntry; use App\Models\List\ExternalProfile; @@ -48,9 +47,6 @@ class PatronRoleSeeder extends RoleSeeder /** @var Role $role */ $role = Role::findOrCreate($roleEnum->value); - // Discord Resources - $this->configureResource($role, DiscordThread::class, [CrudPermission::VIEW]); - // List Resources $this->configureResource($role, ExternalEntry::class, [CrudPermission::VIEW]); $this->configureResource($role, ExternalProfile::class, CrudPermission::cases()); diff --git a/lang/en/filament.php b/lang/en/filament.php index d0931bc68..44527133a 100644 --- a/lang/en/filament.php +++ b/lang/en/filament.php @@ -71,9 +71,6 @@ return [ ], 'name' => 'Backfill Anime', ], - 'discord_thread' => [ - 'name' => 'Create Discord Thread', - ], ], 'audio' => [ 'delete' => [ @@ -100,12 +97,6 @@ return [ 'restore' => 'Restore', 'view' => 'View', ], - 'discord' => [ - 'thread' => [ - 'name' => 'Name', - 'help' => 'The name of the thread to be created. Use the default name or a shorter synonym if it exceeds 100 characters.', - ], - ], 'dump' => [ 'dump' => [ 'confirmButtonText' => 'Dump', @@ -691,16 +682,6 @@ return [ 'timestamps' => 'Timestamps', 'updated_at' => 'Updated At', ], - 'discord_thread' => [ - 'id' => [ - 'help' => 'The thread ID on Discord', - 'name' => 'Thread ID', - ], - 'name' => [ - 'help' => 'The name of the thread on Discord', - 'name' => 'Name', - ], - ], 'dump' => [ 'path' => 'Path', 'public' => 'Public', @@ -1041,7 +1022,6 @@ return [ 'announcements' => 'Announcements', 'artists' => 'Artists', 'audios' => 'Audios', - 'discord_threads' => 'Threads', 'dumps' => 'Dumps', 'external_entries' => 'External Entries', 'external_profiles' => 'External Profiles', @@ -1078,7 +1058,6 @@ return [ 'announcement' => 'Announcement', 'artist' => 'Artist', 'audio' => 'Audio', - 'discord_thread' => 'Thread', 'dump' => 'Dump', 'external_entry' => 'External Entry', 'external_profile' => 'External Profile', diff --git a/tests/Feature/Console/Commands/Storage/Admin/DiscordDumpTest.php b/tests/Feature/Console/Commands/Storage/Admin/DiscordDumpTest.php deleted file mode 100644 index f07085ade..000000000 --- a/tests/Feature/Console/Commands/Storage/Admin/DiscordDumpTest.php +++ /dev/null @@ -1,35 +0,0 @@ -iso8601()); - - $this->artisan(DiscordDumpCommand::class) - ->assertSuccessful() - ->expectsOutputToContain('has been created'); -}); - -test('database dump file', function (): void { - $local = Storage::fake('local'); - $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); - - Date::setTestNow(fake()->iso8601()); - - $this->artisan(DiscordDumpCommand::class)->run(); - - $this->assertEmpty($local->allFiles()); - $this->assertCount(1, $fs->allFiles()); -}); diff --git a/tests/Feature/Filament/Resources/Discord/DiscordThreadTest.php b/tests/Feature/Filament/Resources/Discord/DiscordThreadTest.php deleted file mode 100644 index 54c5a6c92..000000000 --- a/tests/Feature/Filament/Resources/Discord/DiscordThreadTest.php +++ /dev/null @@ -1,116 +0,0 @@ -withPermissions( - SpecialPermission::VIEW_FILAMENT->value, - CrudPermission::VIEW->format(DiscordThreadModel::class) - ) - ->createOne(); - - actingAs($user); - - $records = DiscordThreadModel::factory() - ->for(Anime::factory()) - ->count(10) - ->create(); - - get(DiscordThreadResource::getUrl('index')) - ->assertSuccessful(); - - Livewire::test(getIndexPage(DiscordThreadResource::class)) - ->assertCanSeeTableRecords($records); -}); - -test('render view page', function (): void { - $user = User::factory() - ->withPermissions( - SpecialPermission::VIEW_FILAMENT->value, - CrudPermission::VIEW->format(DiscordThreadModel::class) - ) - ->createOne(); - - actingAs($user); - - $record = DiscordThreadModel::factory() - ->for(Anime::factory()) - ->createOne(); - - get(DiscordThreadResource::getUrl('view', ['record' => $record])) - ->assertSuccessful(); -}); - -test('mount create action', function (): void { - $user = User::factory() - ->withPermissions( - SpecialPermission::VIEW_FILAMENT->value, - CrudPermission::CREATE->format(DiscordThreadModel::class) - ) - ->createOne(); - - actingAs($user); - - Livewire::test(getIndexPage(DiscordThreadResource::class)) - ->mountAction(CreateAction::class) - ->assertActionMounted(CreateAction::class); -}); - -test('mount edit action', function (): void { - $user = User::factory() - ->withPermissions( - SpecialPermission::VIEW_FILAMENT->value, - CrudPermission::UPDATE->format(DiscordThreadModel::class) - ) - ->createOne(); - - actingAs($user); - - $record = DiscordThreadModel::factory() - ->for(Anime::factory()) - ->createOne(); - - Livewire::test(getIndexPage(DiscordThreadResource::class)) - ->mountAction(TestAction::make(EditAction::getDefaultName())->table($record)) - ->callMountedAction() - ->assertHasNoErrors(); -}); - -test('user cannot create record', function (): void { - Livewire::test(getIndexPage(DiscordThreadResource::class)) - ->assertActionHidden(CreateAction::class); -}); - -test('user cannot edit record', function (): void { - $record = DiscordThreadModel::factory() - ->for(Anime::factory()) - ->createOne(); - - Livewire::test(getIndexPage(DiscordThreadResource::class)) - ->assertActionDoesNotExist(TestAction::make(EditAction::getDefaultName())->table($record)); -}); - -test('user cannot delete record', function (): void { - $record = DiscordThreadModel::factory() - ->for(Anime::factory()) - ->createOne(); - - Livewire::test(getIndexPage(DiscordThreadResource::class)) - ->assertActionDoesNotExist(TestAction::make(DeleteAction::getDefaultName())->table($record)); -}); diff --git a/tests/Feature/Jobs/Discord/DiscordThreadTest.php b/tests/Feature/Jobs/Discord/DiscordThreadTest.php deleted file mode 100644 index 4a3fe4750..000000000 --- a/tests/Feature/Jobs/Discord/DiscordThreadTest.php +++ /dev/null @@ -1,49 +0,0 @@ -for(Anime::factory()) - ->createOne(); - - Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); - Bus::fake(SendDiscordNotificationJob::class); - Http::fake(); - Event::fakeExcept(DiscordThreadDeleted::class); - - $thread->delete(); - - Bus::assertDispatched(SendDiscordNotificationJob::class); -}); - -test('thread updated sends discord notification', function (): void { - $thread = DiscordThread::factory() - ->for(Anime::factory()) - ->createOne(); - - Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); - Bus::fake(SendDiscordNotificationJob::class); - Http::fake(); - Event::fakeExcept(DiscordThreadUpdated::class); - - $changes = DiscordThread::factory() - ->for(Anime::factory()) - ->makeOne(); - - $thread->fill($changes->getAttributes()); - $thread->save(); - - Bus::assertDispatched(SendDiscordNotificationJob::class); -}); diff --git a/tests/Unit/Models/Discord/DiscordThreadTest.php b/tests/Unit/Models/Discord/DiscordThreadTest.php deleted file mode 100644 index f90675e7c..000000000 --- a/tests/Unit/Models/Discord/DiscordThreadTest.php +++ /dev/null @@ -1,35 +0,0 @@ -for(Anime::factory()) - ->createOne(); - - $this->assertIsString($thread->getName()); -}); - -test('has subtitle', function (): void { - $thread = DiscordThread::factory() - ->for(Anime::factory()) - ->createOne(); - - $this->assertIsString($thread->getSubtitle()); -}); - -test('anime', function (): void { - $thread = DiscordThread::factory() - ->for(Anime::factory()) - ->createOne(); - - $this->assertInstanceOf(BelongsTo::class, $thread->anime()); - $this->assertInstanceOf(Anime::class, $thread->anime()->first()); -});