diff options
| author | winter | 2025-03-15 21:57:00 +0000 |
|---|---|---|
| committer | winter | 2025-03-15 21:57:00 +0000 |
| commit | d5dd9044632320e625ce90ae9627ebc11c7a04d6 (patch) | |
| tree | b5466a37f464e9b3ba43c7ed0d232afc442f656b /Digitigrade/Notification | |
| parent | 8843a8cb197e71b1ca42f1ea56be5f806ad0f5b4 (diff) | |
send notification to author when admin edits note
Diffstat (limited to 'Digitigrade/Notification')
| -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 |
