From d5dd9044632320e625ce90ae9627ebc11c7a04d6 Mon Sep 17 00:00:00 2001 From: winter Date: Sat, 15 Mar 2025 21:57:00 +0000 Subject: send notification to author when admin edits note --- Digitigrade/Notification/AdminEditedNoteNotif.php | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Digitigrade/Notification/AdminEditedNoteNotif.php (limited to 'Digitigrade/Notification') 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 @@ +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 -- cgit v1.3