diff options
Diffstat (limited to 'Digitigrade/Notification/AdminEditedNoteNotif.php')
| -rw-r--r-- | Digitigrade/Notification/AdminEditedNoteNotif.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Digitigrade/Notification/AdminEditedNoteNotif.php b/Digitigrade/Notification/AdminEditedNoteNotif.php new file mode 100644 index 0000000..f3c18a1 --- /dev/null +++ b/Digitigrade/Notification/AdminEditedNoteNotif.php @@ -0,0 +1,43 @@ +<?php +namespace Digitigrade\Notification; + +use Digitigrade\Model\Note; +use Digitigrade\Model\UserAccount; + +class AdminEditedNoteNotif implements Notifyable { + private UserAccount $admin; + private Note $note; + + public function __construct(UserAccount $admin, Note $note) { + $this->admin = $admin; + $this->note = $note; + } + + public function toJsonReference(): mixed { + return [$this->admin->id, $this->note->id]; + } + + public static function fromJsonReference(mixed $reference): self { + return new self(UserAccount::find($reference[0]), Note::find($reference[1])); + } + + public function getNotificationTitle(): string { + return __f('notification.adminEditedNote', $this->admin->actor->displayName); + } + + public function getNotificationTitleLink(): ?string { + return $this->note->getLocalUiHref(); + } + + public function getNotificationBody(): ?string { + return isset($this->note->summary) ? ('[' . $this->note->summary . ']') : $this->note->plainContent; + } + + public function getNotificationImageUrl(): ?string { + return $this->admin->actor->avatar ?? '/static/default-avatar.png'; + } + + public function getNotificationImageLink(): ?string { + return $this->admin->actor->getLocalUiHref(); + } +}
\ No newline at end of file |
