aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade
diff options
context:
space:
mode:
authorwinter2025-03-15 21:57:00 +0000
committerwinter2025-03-15 21:57:00 +0000
commitd5dd9044632320e625ce90ae9627ebc11c7a04d6 (patch)
treeb5466a37f464e9b3ba43c7ed0d232afc442f656b /Digitigrade
parent8843a8cb197e71b1ca42f1ea56be5f806ad0f5b4 (diff)
send notification to author when admin edits note
Diffstat (limited to 'Digitigrade')
-rw-r--r--Digitigrade/Notification/AdminEditedNoteNotif.php43
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