feat(admin): add password reset link action (#1138)

This commit is contained in:
Kyrch
2026-03-25 20:05:29 -03:00
committed by GitHub
parent 37076c44cd
commit d2055c3726
159 changed files with 307 additions and 741 deletions
@@ -10,10 +10,4 @@ use App\Models\Admin\Announcement;
/**
* @extends AdminCreatedEvent<Announcement>
*/
class AnnouncementCreated extends AdminCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Announcement '**{$this->getModel()->getName()}**' has been created.";
}
}
class AnnouncementCreated extends AdminCreatedEvent {}
@@ -10,10 +10,4 @@ use App\Models\Admin\Announcement;
/**
* @extends AdminDeletedEvent<Announcement>
*/
class AnnouncementDeleted extends AdminDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Announcement '**{$this->getModel()->getName()}**' has been deleted.";
}
}
class AnnouncementDeleted extends AdminDeletedEvent {}
@@ -17,9 +17,4 @@ class AnnouncementUpdated extends AdminUpdatedEvent
parent::__construct($announcement);
$this->initializeEmbedFields($announcement);
}
protected function getDiscordMessageDescription(): string
{
return "Announcement '**{$this->getModel()->getName()}**' has been updated.";
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Admin\Dump;
/**
* @extends AdminCreatedEvent<Dump>
*/
class DumpCreated extends AdminCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Dump '**{$this->getModel()->getName()}**' has been created.";
}
}
class DumpCreated extends AdminCreatedEvent {}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Admin\Dump;
/**
* @extends AdminDeletedEvent<Dump>
*/
class DumpDeleted extends AdminDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Dump '**{$this->getModel()->getName()}**' has been deleted.";
}
}
class DumpDeleted extends AdminDeletedEvent {}
-5
View File
@@ -17,9 +17,4 @@ class DumpUpdated extends AdminUpdatedEvent
parent::__construct($dump);
$this->initializeEmbedFields($dump);
}
protected function getDiscordMessageDescription(): string
{
return "Dump '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -12,11 +12,6 @@ use App\Models\Admin\Feature;
*/
class FeatureCreated extends AdminCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Feature '**{$this->getModel()->getName()}**' has been created.";
}
public function shouldSendDiscordMessage(): bool
{
return $this->getModel()->isNullScope();
@@ -12,11 +12,6 @@ use App\Models\Admin\Feature;
*/
class FeatureDeleted extends AdminDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Feature '**{$this->getModel()->getName()}**' has been deleted.";
}
public function shouldSendDiscordMessage(): bool
{
return $this->getModel()->isNullScope();
@@ -18,11 +18,6 @@ class FeatureUpdated extends AdminUpdatedEvent
$this->initializeEmbedFields($feature);
}
protected function getDiscordMessageDescription(): string
{
return "Feature '**{$this->getModel()->getName()}**' has been updated.";
}
public function shouldSendDiscordMessage(): bool
{
return $this->getModel()->isNullScope();
@@ -10,10 +10,4 @@ use App\Models\Admin\FeaturedTheme;
/**
* @extends AdminCreatedEvent<FeaturedTheme>
*/
class FeaturedThemeCreated extends AdminCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Featured Theme '**{$this->getModel()->getName()}**' has been created.";
}
}
class FeaturedThemeCreated extends AdminCreatedEvent {}
@@ -10,10 +10,4 @@ use App\Models\Admin\FeaturedTheme;
/**
* @extends AdminDeletedEvent<FeaturedTheme>
*/
class FeaturedThemeDeleted extends AdminDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Featured Theme '**{$this->getModel()->getName()}**' has been deleted.";
}
}
class FeaturedThemeDeleted extends AdminDeletedEvent {}
@@ -17,9 +17,4 @@ class FeaturedThemeUpdated extends AdminUpdatedEvent
parent::__construct($featuredTheme);
$this->initializeEmbedFields($featuredTheme);
}
protected function getDiscordMessageDescription(): string
{
return "Featured Theme '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -8,38 +8,35 @@ use App\Constants\Config\ServiceConstants;
use App\Contracts\Events\DiscordMessageEvent;
use App\Contracts\Events\NotifiesUsersEvent;
use App\Enums\Discord\EmbedColor;
use App\Events\BaseEvent;
use App\Models\Auth\Prohibition;
use App\Models\Auth\User;
use App\Notifications\Auth\ProhibitionOrSanctionNotification;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Config;
use NotificationChannels\Discord\DiscordMessage;
class ModelProhibited implements DiscordMessageEvent, NotifiesUsersEvent
class UserProhibited extends BaseEvent implements DiscordMessageEvent, NotifiesUsersEvent
{
use Dispatchable;
use SerializesModels;
/**
* @param User $model
* @param Prohibition $prohibition
* @param User $moderator
*/
public function __construct(
public Model $model,
public mixed $prohibition,
public User $user,
public Prohibition $prohibition,
public ?DateTimeInterface $expiresAt = null,
public ?string $reason = null,
public ?Model $moderator = null,
) {}
public ?User $moderator = null,
) {
parent::__construct($user);
}
public function getDiscordMessage(): DiscordMessage
{
return DiscordMessage::create('', [
'description' => "Prohibition '**{$this->prohibition->name}**' triggered for user '**{$this->model->getName()}**'. Reason: {$this->reason}",
'description' => "Prohibition '**{$this->prohibition->name}**' triggered for user '**{$this->user->getName()}**'. Reason: {$this->reason}",
'color' => EmbedColor::GREEN->value,
]);
}
@@ -56,6 +53,6 @@ class ModelProhibited implements DiscordMessageEvent, NotifiesUsersEvent
public function notify(): void
{
$this->model->notify(new ProhibitionOrSanctionNotification($this->prohibition, $this->reason, $this->expiresAt));
$this->user->notify(new ProhibitionOrSanctionNotification($this->prohibition, $this->reason, $this->expiresAt));
}
}
@@ -8,38 +8,35 @@ use App\Constants\Config\ServiceConstants;
use App\Contracts\Events\DiscordMessageEvent;
use App\Contracts\Events\NotifiesUsersEvent;
use App\Enums\Discord\EmbedColor;
use App\Events\BaseEvent;
use App\Models\Auth\Sanction;
use App\Models\Auth\User;
use App\Notifications\Auth\ProhibitionOrSanctionNotification;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Config;
use NotificationChannels\Discord\DiscordMessage;
class ModelSanctioned implements DiscordMessageEvent, NotifiesUsersEvent
class UserSanctioned extends BaseEvent implements DiscordMessageEvent, NotifiesUsersEvent
{
use Dispatchable;
use SerializesModels;
/**
* @param User $model
* @param Sanction $sanction
* @param User $moderator
*/
public function __construct(
public Model $model,
public mixed $sanction,
public User $user,
public Sanction $sanction,
public ?DateTimeInterface $expiresAt = null,
public ?string $reason = null,
public ?Model $moderator = null,
) {}
public ?User $moderator = null,
) {
parent::__construct($user);
}
public function getDiscordMessage(): DiscordMessage
{
return DiscordMessage::create('', [
'description' => "Sanction '**{$this->sanction->name}**' triggered for user '**{$this->model->getName()}**'. Reason: {$this->reason}",
'description' => "Sanction '**{$this->sanction->name}**' triggered for user '**{$this->user->getName()}**'. Reason: {$this->reason}",
'color' => EmbedColor::GREEN->value,
]);
}
@@ -56,6 +53,6 @@ class ModelSanctioned implements DiscordMessageEvent, NotifiesUsersEvent
public function notify(): void
{
$this->model->notify(new ProhibitionOrSanctionNotification($this->sanction, $this->reason, $this->expiresAt));
$this->user->notify(new ProhibitionOrSanctionNotification($this->sanction, $this->reason, $this->expiresAt));
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Auth\User;
/**
* @extends AdminCreatedEvent<User>
*/
class UserCreated extends AdminCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "User '**{$this->getModel()->getName()}**' has been created.";
}
}
class UserCreated extends AdminCreatedEvent {}
-5
View File
@@ -14,11 +14,6 @@ use App\Models\List\ExternalProfile;
*/
class UserDeleted extends AdminDeletedEvent implements CascadesDeletesEvent
{
protected function getDiscordMessageDescription(): string
{
return "User '**{$this->getModel()->getName()}**' has been deleted.";
}
public function cascadeDeletes(): void
{
$this->getModel()->externalprofiles->each(fn (ExternalProfile $profile) => $profile->delete());
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Auth\User;
/**
* @extends AdminRestoredEvent<User>
*/
class UserRestored extends AdminRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "User '**{$this->getModel()->getName()}**' has been restored.";
}
}
class UserRestored extends AdminRestoredEvent {}
-5
View File
@@ -17,9 +17,4 @@ class UserUpdated extends AdminUpdatedEvent
parent::__construct($user);
$this->initializeEmbedFields($user);
}
protected function getDiscordMessageDescription(): string
{
return "User '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -24,4 +24,9 @@ abstract class AdminCreatedEvent extends BaseCreatedEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been created.";
}
}
@@ -24,4 +24,9 @@ abstract class AdminDeletedEvent extends BaseDeletedEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been deleted.";
}
}
@@ -24,4 +24,9 @@ abstract class AdminRestoredEvent extends BaseRestoredEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been restored.";
}
}
@@ -24,4 +24,9 @@ abstract class AdminUpdatedEvent extends BaseUpdatedEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -19,4 +19,9 @@ abstract class DocumentCreatedEvent extends BaseCreatedEvent
{
return Config::get(ServiceConstants::ADMIN_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been created.";
}
}
@@ -61,10 +61,18 @@ abstract class DocumentDeletedEvent extends BaseDeletedEvent implements Filament
->get();
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "{$this->privateLabel($this->getModel())} '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
/**
* Get the URL for the filament notification.
*/
abstract protected function getFilamentNotificationUrl(): string;
abstract protected function getNotificationMessage(): string;
}
@@ -19,4 +19,9 @@ abstract class DocumentRestoredEvent extends BaseRestoredEvent
{
return Config::get(ServiceConstants::ADMIN_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been restored.";
}
}
@@ -19,4 +19,9 @@ abstract class DocumentUpdatedEvent extends BaseUpdatedEvent
{
return Config::get(ServiceConstants::ADMIN_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -24,4 +24,9 @@ abstract class ListCreatedEvent extends BaseCreatedEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been created.";
}
}
@@ -24,4 +24,9 @@ abstract class ListDeletedEvent extends BaseDeletedEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been deleted.";
}
}
@@ -24,4 +24,9 @@ abstract class ListRestoredEvent extends BaseRestoredEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been restored.";
}
}
@@ -24,4 +24,9 @@ abstract class ListUpdatedEvent extends BaseUpdatedEvent
{
return true;
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -19,4 +19,9 @@ abstract class WikiCreatedEvent extends BaseCreatedEvent
{
return Config::get(ServiceConstants::DB_UPDATES_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been created.";
}
}
+10 -2
View File
@@ -29,6 +29,16 @@ abstract class WikiDeletedEvent extends BaseDeletedEvent implements FilamentNoti
return Config::get(ServiceConstants::DB_UPDATES_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getNotificationMessage(): string
{
return "{$this->privateLabel($this->getModel())} '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
public function shouldSendFilamentNotification(): bool
{
$model = $this->getModel();
@@ -65,6 +75,4 @@ abstract class WikiDeletedEvent extends BaseDeletedEvent implements FilamentNoti
* Get the URL for the filament notification.
*/
abstract protected function getFilamentNotificationUrl(): string;
abstract protected function getNotificationMessage(): string;
}
@@ -19,4 +19,9 @@ abstract class WikiRestoredEvent extends BaseRestoredEvent
{
return Config::get(ServiceConstants::DB_UPDATES_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been restored.";
}
}
@@ -19,4 +19,9 @@ abstract class WikiUpdatedEvent extends BaseUpdatedEvent
{
return Config::get(ServiceConstants::DB_UPDATES_DISCORD_CHANNEL_QUALIFIED);
}
protected function getDiscordMessageDescription(): string
{
return "{$this->privateLabel($this->getModel())} '**{$this->getModel()->getName()}**' has been updated.";
}
}
+3
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Events;
use App\Concerns\Models\HasLabel;
use App\Contracts\Models\Nameable;
use App\Models\Auth\User;
use Illuminate\Database\Eloquent\Model;
@@ -14,6 +15,8 @@ use Illuminate\Support\Facades\Auth;
*/
abstract class BaseEvent
{
use HasLabel;
protected ?User $authenticatedUser;
/**
@@ -10,10 +10,4 @@ use App\Models\Discord\DiscordThread;
/**
* @extends AdminDeletedEvent<DiscordThread>
*/
class DiscordThreadDeleted extends AdminDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Discord Thread '**{$this->getModel()->getName()}**' has been deleted.";
}
}
class DiscordThreadDeleted extends AdminDeletedEvent {}
@@ -17,9 +17,4 @@ class DiscordThreadUpdated extends AdminUpdatedEvent
parent::__construct($thread);
$this->initializeEmbedFields($thread);
}
protected function getDiscordMessageDescription(): string
{
return "Discord Thread '**{$this->getModel()->getName()}**' has been updated.";
}
}
-5
View File
@@ -14,11 +14,6 @@ use App\Models\Document\Page;
*/
class PageCreated extends DocumentCreatedEvent implements UpdateRelationsEvent
{
protected function getDiscordMessageDescription(): string
{
return "Page '**{$this->getModel()->getName()}**' has been created.";
}
public function updateRelations(): void
{
new UpdatePageRelations()->handle($this->getModel());
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Document\Page;
*/
class PageDeleted extends DocumentDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Page '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Page '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return PageFilament::getUrl('view', ['record' => $this->getModel()]);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Document\Page;
/**
* @extends DocumentRestoredEvent<Page>
*/
class PageRestored extends DocumentRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Page '**{$this->getModel()->getName()}**' has been restored.";
}
}
class PageRestored extends DocumentRestoredEvent {}
-5
View File
@@ -20,11 +20,6 @@ class PageUpdated extends DocumentUpdatedEvent implements UpdateRelationsEvent
$this->initializeEmbedFields($page);
}
protected function getDiscordMessageDescription(): string
{
return "Page '**{$this->getModel()->getName()}**' has been updated.";
}
public function updateRelations(): void
{
new UpdatePageRelations()->handle($this->getModel());
@@ -10,10 +10,4 @@ use App\Models\List\ExternalProfile;
/**
* @extends ListCreatedEvent<ExternalProfile>
*/
class ExternalProfileCreated extends ListCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "External Profile '**{$this->getModel()->getName()}**' has been created.";
}
}
class ExternalProfileCreated extends ListCreatedEvent {}
@@ -16,9 +16,4 @@ class ExternalProfileDeleted extends ListDeletedEvent
{
return false;
}
protected function getDiscordMessageDescription(): string
{
return "External Profile '**{$this->getModel()->getName()}**' has been deleted.";
}
}
@@ -22,9 +22,4 @@ class ExternalProfileUpdated extends ListUpdatedEvent
{
return false;
}
protected function getDiscordMessageDescription(): string
{
return "External Profile '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -18,11 +18,6 @@ class PlaylistCreated extends ListCreatedEvent implements AssignHashidsEvent
return $this->model;
}
protected function getDiscordMessageDescription(): string
{
return "Playlist '**{$this->getModel()->getName()}**' has been created.";
}
/**
* Get the Hashids connection.
*
@@ -16,9 +16,4 @@ class PlaylistDeleted extends ListDeletedEvent
{
return false;
}
protected function getDiscordMessageDescription(): string
{
return "Playlist '**{$this->getModel()->getName()}**' has been deleted.";
}
}
@@ -22,9 +22,4 @@ class PlaylistUpdated extends ListUpdatedEvent
{
return false;
}
protected function getDiscordMessageDescription(): string
{
return "Playlist '**{$this->getModel()->getName()}**' has been updated.";
}
}
-5
View File
@@ -16,11 +16,6 @@ use App\Models\Wiki\Video;
*/
class AnimeCreated extends WikiCreatedEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Anime '**{$this->getModel()->getName()}**' has been created.";
}
public function updateRelatedIndices(): void
{
$anime = $this->getModel()->load(Anime::RELATION_VIDEOS);
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Wiki\Anime;
*/
class AnimeDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Anime '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Anime '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return AnimeFilament::getUrl('view', ['record' => $this->getModel()]);
-5
View File
@@ -18,11 +18,6 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
*/
class AnimeRestored extends WikiRestoredEvent implements CascadesRestoresEvent
{
protected function getDiscordMessageDescription(): string
{
return "Anime '**{$this->getModel()->getName()}**' has been restored.";
}
public function cascadeRestores(): void
{
$anime = $this->getModel();
-5
View File
@@ -22,11 +22,6 @@ class AnimeUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent
$this->initializeEmbedFields($anime);
}
protected function getDiscordMessageDescription(): string
{
return "Anime '**{$this->getModel()->getName()}**' has been updated.";
}
public function updateRelatedIndices(): void
{
$anime = $this->getModel()->load(Anime::RELATION_VIDEOS);
@@ -14,11 +14,6 @@ use App\Models\Wiki\Video;
*/
class EntryCreated extends WikiCreatedEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Entry '**{$this->getModel()->getName()}**' has been created.";
}
public function updateRelatedIndices(): void
{
$entry = $this->getModel();
@@ -15,16 +15,6 @@ use App\Models\Wiki\Video;
*/
class EntryDeleted extends WikiDeletedEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Entry '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Entry '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return EntryFilament::getUrl('view', ['record' => $this->getModel()]);
@@ -12,17 +12,15 @@ use App\Models\Wiki\Video;
/**
* @extends BaseEvent<AnimeThemeEntry>
*/
class EntryDeleting extends BaseEvent implements UpdateRelatedIndicesEvent
class EntryForceDeleting extends BaseEvent implements UpdateRelatedIndicesEvent
{
public function updateRelatedIndices(): void
{
$entry = $this->getModel();
if ($entry->isForceDeleting()) {
// refresh video documents by detaching entry
$videos = $entry->videos;
$entry->videos()->detach();
$videos->each(fn (Video $video) => $video->searchable());
}
// refresh video documents by detaching entry
$videos = $entry->videos;
$entry->videos()->detach();
$videos->each(fn (Video $video) => $video->searchable());
}
}
@@ -14,11 +14,6 @@ use App\Models\Wiki\Video;
*/
class EntryRestored extends WikiRestoredEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Entry '**{$this->getModel()->getName()}**' has been restored.";
}
public function updateRelatedIndices(): void
{
$entry = $this->getModel();
@@ -20,11 +20,6 @@ class EntryUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent
$this->initializeEmbedFields($entry);
}
protected function getDiscordMessageDescription(): string
{
return "Entry '**{$this->getModel()->getName()}**' has been updated.";
}
public function updateRelatedIndices(): void
{
$entry = $this->getModel();
@@ -15,11 +15,6 @@ use App\Models\Wiki\Video;
*/
class ThemeCreated extends WikiCreatedEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Theme '**{$this->getModel()->getName()}**' has been created for Anime '**{$this->getModel()->anime->getName()}**'.";
}
public function updateRelatedIndices(): void
{
$theme = $this->getModel()->load(AnimeTheme::RELATION_VIDEOS);
@@ -13,16 +13,6 @@ use App\Models\Wiki\Anime\AnimeTheme;
*/
class ThemeDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Theme '**{$this->getModel()->getName()}**' has been deleted for Anime '**{$this->getModel()->anime->getName()}**'.";
}
protected function getNotificationMessage(): string
{
return "Theme '{$this->getModel()->getName()}' has been deleted for Anime '{$this->getModel()->anime->getName()}'. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return ThemeFilament::getUrl('view', ['record' => $this->getModel()]);
@@ -16,11 +16,6 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
*/
class ThemeRestored extends WikiRestoredEvent implements CascadesRestoresEvent
{
protected function getDiscordMessageDescription(): string
{
return "Theme '**{$this->getModel()->getName()}**' has been restored for Anime '**{$this->getModel()->anime->getName()}**'.";
}
public function cascadeRestores(): void
{
$theme = $this->getModel();
@@ -22,11 +22,6 @@ class ThemeUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent
$this->initializeEmbedFields($theme);
}
protected function getDiscordMessageDescription(): string
{
return "Theme '**{$this->getModel()->getName()}**' has been updated for Anime '**{$this->getModel()->anime->getName()}**'.";
}
public function updateRelatedIndices(): void
{
$theme = $this->getModel()->load(AnimeTheme::RELATION_VIDEOS);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Artist;
/**
* @extends WikiCreatedEvent<Artist>
*/
class ArtistCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Artist '**{$this->getModel()->getName()}**' has been created.";
}
}
class ArtistCreated extends WikiCreatedEvent {}
-10
View File
@@ -16,16 +16,6 @@ use App\Models\Wiki\Song\Performance;
*/
class ArtistDeleted extends WikiDeletedEvent implements CascadesDeletesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Artist '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Artist '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return ArtistFilament::getUrl('view', ['record' => $this->getModel()]);
@@ -16,11 +16,6 @@ use App\Models\Wiki\Song\Performance;
*/
class ArtistForceDeleted extends WikiDeletedEvent implements CascadesDeletesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Artist '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Artist '{$this->getModel()->getName()}' has been deleted.";
@@ -16,11 +16,6 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
*/
class ArtistRestored extends WikiRestoredEvent implements CascadesRestoresEvent
{
protected function getDiscordMessageDescription(): string
{
return "Artist '**{$this->getModel()->getName()}**' has been restored.";
}
public function cascadeRestores(): void
{
$this->getModel()->withoutGlobalScope(SoftDeletingScope::class)->with([
-5
View File
@@ -17,9 +17,4 @@ class ArtistUpdated extends WikiUpdatedEvent
parent::__construct($artist);
$this->initializeEmbedFields($artist);
}
protected function getDiscordMessageDescription(): string
{
return "Artist '**{$this->getModel()->getName()}**' has been updated.";
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Audio;
/**
* @extends WikiCreatedEvent<Audio>
*/
class AudioCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Audio '**{$this->getModel()->getName()}**' has been created.";
}
}
class AudioCreated extends WikiCreatedEvent {}
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Wiki\Audio;
*/
class AudioDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Audio '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Audio '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return AudioFilament::getUrl('view', ['record' => $this->getModel()]);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Audio;
/**
* @extends WikiRestoredEvent<Audio>
*/
class AudioRestored extends WikiRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Audio '**{$this->getModel()->getName()}**' has been restored.";
}
}
class AudioRestored extends WikiRestoredEvent {}
-5
View File
@@ -17,9 +17,4 @@ class AudioUpdated extends WikiUpdatedEvent
parent::__construct($audio);
$this->initializeEmbedFields($audio);
}
protected function getDiscordMessageDescription(): string
{
return "Audio '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -10,10 +10,4 @@ use App\Models\Wiki\ExternalResource;
/**
* @extends WikiCreatedEvent<ExternalResource>
*/
class ExternalResourceCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Resource '**{$this->getModel()->getName()}**' has been created.";
}
}
class ExternalResourceCreated extends WikiCreatedEvent {}
@@ -13,16 +13,6 @@ use App\Models\Wiki\ExternalResource;
*/
class ExternalResourceDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Resource '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Resource '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return ExternalResourceFilament::getUrl('view', ['record' => $this->getModel()]);
@@ -10,10 +10,4 @@ use App\Models\Wiki\ExternalResource;
/**
* @extends WikiRestoredEvent<ExternalResource>
*/
class ExternalResourceRestored extends WikiRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Resource '**{$this->getModel()->getName()}**' has been restored.";
}
}
class ExternalResourceRestored extends WikiRestoredEvent {}
@@ -17,9 +17,4 @@ class ExternalResourceUpdated extends WikiUpdatedEvent
parent::__construct($resource);
$this->initializeEmbedFields($resource);
}
protected function getDiscordMessageDescription(): string
{
return "Resource '**{$this->getModel()->getName()}**' has been updated.";
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Group;
/**
* @extends WikiCreatedEvent<Group>
*/
class GroupCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Group '**{$this->getModel()->getName()}**' has been created.";
}
}
class GroupCreated extends WikiCreatedEvent {}
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Wiki\Group;
*/
class GroupDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Group '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Group '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return GroupFilament::getUrl('view', ['record' => $this->getModel()]);
-30
View File
@@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Events\Wiki\Group;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\BaseEvent;
use App\Models\Wiki\Anime\AnimeTheme;
use App\Models\Wiki\Group;
/**
* @extends BaseEvent<Group>
*/
class GroupDeleting extends BaseEvent implements UpdateRelatedIndicesEvent
{
public function updateRelatedIndices(): void
{
$group = $this->getModel()->load(Group::RELATION_VIDEOS);
if ($group->isForceDeleting()) {
$group->animethemes->each(function (AnimeTheme $theme): void {
AnimeTheme::withoutEvents(function () use ($theme): void {
$theme->group()->dissociate();
$theme->save();
});
});
}
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Group;
/**
* @extends WikiRestoredEvent<Group>
*/
class GroupRestored extends WikiRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Group '**{$this->getModel()->getName()}**' has been restored.";
}
}
class GroupRestored extends WikiRestoredEvent {}
-5
View File
@@ -17,9 +17,4 @@ class GroupUpdated extends WikiUpdatedEvent
parent::__construct($group);
$this->initializeEmbedFields($group);
}
protected function getDiscordMessageDescription(): string
{
return "Group '**{$this->getModel()->getName()}**' has been updated.";
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Image;
/**
* @extends WikiCreatedEvent<Image>
*/
class ImageCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Image '**{$this->getModel()->getName()}**' has been created.";
}
}
class ImageCreated extends WikiCreatedEvent {}
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Wiki\Image;
*/
class ImageDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Image '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Image '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return ImageFilament::getUrl('view', ['record' => $this->getModel()]);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Image;
/**
* @extends WikiRestoredEvent<Image>
*/
class ImageRestored extends WikiRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Image '**{$this->getModel()->getName()}**' has been restored.";
}
}
class ImageRestored extends WikiRestoredEvent {}
-5
View File
@@ -17,9 +17,4 @@ class ImageUpdated extends WikiUpdatedEvent
parent::__construct($image);
$this->initializeEmbedFields($image);
}
protected function getDiscordMessageDescription(): string
{
return "Image '**{$this->getModel()->getName()}**' has been updated.";
}
}
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Series;
/**
* @extends WikiCreatedEvent<Series>
*/
class SeriesCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Series '**{$this->getModel()->getName()}**' has been created.";
}
}
class SeriesCreated extends WikiCreatedEvent {}
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Wiki\Series;
*/
class SeriesDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Series '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Series '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return SeriesFilament::getUrl('view', ['record' => $this->getModel()]);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Series;
/**
* @extends WikiRestoredEvent<Series>
*/
class SeriesRestored extends WikiRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Series '**{$this->getModel()->getName()}**' has been restored.";
}
}
class SeriesRestored extends WikiRestoredEvent {}
-5
View File
@@ -17,9 +17,4 @@ class SeriesUpdated extends WikiUpdatedEvent
parent::__construct($series);
$this->initializeEmbedFields($series);
}
protected function getDiscordMessageDescription(): string
{
return "Series '**{$this->getModel()->getName()}**' has been updated.";
}
}
-5
View File
@@ -16,11 +16,6 @@ use App\Models\Wiki\Video;
*/
class SongCreated extends WikiCreatedEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Song '**{$this->getModel()->getName()}**' has been created.";
}
public function updateRelatedIndices(): void
{
$song = $this->getModel()->load([Song::RELATION_VIDEOS]);
-10
View File
@@ -17,16 +17,6 @@ use App\Models\Wiki\Video;
*/
class SongDeleted extends WikiDeletedEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Song '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Song '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return SongFilament::getUrl('view', ['record' => $this->getModel()]);
-38
View File
@@ -1,38 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Events\Wiki\Song;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\BaseEvent;
use App\Models\Wiki\Anime\AnimeTheme;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Models\Wiki\Song;
use App\Models\Wiki\Video;
/**
* @extends BaseEvent<Song>
*/
class SongDeleting extends BaseEvent implements UpdateRelatedIndicesEvent
{
public function updateRelatedIndices(): void
{
$song = $this->getModel()->load([Song::RELATION_VIDEOS]);
if ($song->isForceDeleting()) {
// refresh theme documents by dissociating song
$song->animethemes->each(function (AnimeTheme $theme): void {
AnimeTheme::withoutEvents(function () use ($theme): void {
$theme->song()->dissociate();
$theme->save();
});
$theme->searchable();
$theme->animethemeentries->each(function (AnimeThemeEntry $entry): void {
$entry->searchable();
$entry->videos->each(fn (Video $video) => $video->searchable());
});
});
}
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Events\Wiki\Song;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\BaseEvent;
use App\Models\Wiki\Anime\AnimeTheme;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Models\Wiki\Song;
use App\Models\Wiki\Video;
/**
* @extends BaseEvent<Song>
*/
class SongForceDeleting extends BaseEvent implements UpdateRelatedIndicesEvent
{
public function updateRelatedIndices(): void
{
$song = $this->getModel()->load([Song::RELATION_VIDEOS]);
// refresh theme documents by dissociating song
$song->animethemes->each(function (AnimeTheme $theme): void {
AnimeTheme::withoutEvents(function () use ($theme): void {
$theme->song()->dissociate();
$theme->save();
});
$theme->searchable();
$theme->animethemeentries->each(function (AnimeThemeEntry $entry): void {
$entry->searchable();
$entry->videos->each(fn (Video $video) => $video->searchable());
});
});
}
}
-5
View File
@@ -16,11 +16,6 @@ use App\Models\Wiki\Video;
*/
class SongRestored extends WikiRestoredEvent implements UpdateRelatedIndicesEvent
{
protected function getDiscordMessageDescription(): string
{
return "Song '**{$this->getModel()->getName()}**' has been restored.";
}
public function updateRelatedIndices(): void
{
$song = $this->getModel()->load([Song::RELATION_VIDEOS]);
-5
View File
@@ -22,11 +22,6 @@ class SongUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent
$this->initializeEmbedFields($song);
}
protected function getDiscordMessageDescription(): string
{
return "Song '**{$this->getModel()->getName()}**' has been updated.";
}
public function updateRelatedIndices(): void
{
$song = $this->getModel()->load([Song::RELATION_VIDEOS]);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Studio;
/**
* @extends WikiCreatedEvent<Studio>
*/
class StudioCreated extends WikiCreatedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Studio '**{$this->getModel()->getName()}**' has been created.";
}
}
class StudioCreated extends WikiCreatedEvent {}
-10
View File
@@ -13,16 +13,6 @@ use App\Models\Wiki\Studio;
*/
class StudioDeleted extends WikiDeletedEvent
{
protected function getDiscordMessageDescription(): string
{
return "Studio '**{$this->getModel()->getName()}**' has been deleted.";
}
protected function getNotificationMessage(): string
{
return "Studio '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review.";
}
protected function getFilamentNotificationUrl(): string
{
return StudioFilament::getUrl('view', ['record' => $this->getModel()]);
+1 -7
View File
@@ -10,10 +10,4 @@ use App\Models\Wiki\Studio;
/**
* @extends WikiRestoredEvent<Studio>
*/
class StudioRestored extends WikiRestoredEvent
{
protected function getDiscordMessageDescription(): string
{
return "Studio '**{$this->getModel()->getName()}**' has been restored.";
}
}
class StudioRestored extends WikiRestoredEvent {}
-5
View File
@@ -17,9 +17,4 @@ class StudioUpdated extends WikiUpdatedEvent
parent::__construct($studio);
$this->initializeEmbedFields($studio);
}
protected function getDiscordMessageDescription(): string
{
return "Studio '**{$this->getModel()->getName()}**' has been updated.";
}
}
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Events\Wiki\Synonym;
use App\Concerns\Models\HasLabel;
use App\Contracts\Events\UpdateAnimeSynonymsEvent;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\Base\Wiki\WikiCreatedEvent;
@@ -22,8 +21,6 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
*/
class SynonymCreated extends WikiCreatedEvent implements UpdateAnimeSynonymsEvent, UpdateRelatedIndicesEvent
{
use HasLabel;
protected function getDiscordMessageDescription(): string
{
return "Synonym '**{$this->getModel()->getName()}**' has been created for {$this->privateLabel($this->getModel()->synonymable)} '**{$this->getModel()->synonymable->getName()}**'.";
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Events\Wiki\Synonym;
use App\Concerns\Models\HasLabel;
use App\Contracts\Events\UpdateAnimeSynonymsEvent;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\Base\Wiki\WikiDeletedEvent;
@@ -23,8 +22,6 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
*/
class SynonymDeleted extends WikiDeletedEvent implements UpdateAnimeSynonymsEvent, UpdateRelatedIndicesEvent
{
use HasLabel;
protected function getDiscordMessageDescription(): string
{
return "Synonym '**{$this->getModel()->getName()}**' has been deleted for {$this->privateLabel($this->getModel()->synonymable)} '**{$this->getModel()->synonymable->getName()}**'.";
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Events\Wiki\Synonym;
use App\Concerns\Models\HasLabel;
use App\Contracts\Events\UpdateAnimeSynonymsEvent;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\Base\Wiki\WikiRestoredEvent;
@@ -22,8 +21,6 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
*/
class SynonymRestored extends WikiRestoredEvent implements UpdateAnimeSynonymsEvent, UpdateRelatedIndicesEvent
{
use HasLabel;
protected function getDiscordMessageDescription(): string
{
return "Synonym '**{$this->getModel()->getName()}**' has been restored for {$this->privateLabel($this->getModel()->synonymable)} '**{$this->getModel()->synonymable->getName()}**'.";
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Events\Wiki\Synonym;
use App\Concerns\Models\HasLabel;
use App\Contracts\Events\UpdateAnimeSynonymsEvent;
use App\Contracts\Events\UpdateRelatedIndicesEvent;
use App\Events\Base\Wiki\WikiUpdatedEvent;
@@ -22,8 +21,6 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
*/
class SynonymUpdated extends WikiUpdatedEvent implements UpdateAnimeSynonymsEvent, UpdateRelatedIndicesEvent
{
use HasLabel;
public function __construct(Synonym $synonym)
{
parent::__construct($synonym);

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