From b8e259f75dfa52584d7483313b0c6814867d2330 Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 20 Jan 2025 18:20:45 +0000 Subject: follow, unfollow, follow request notifications --- Digitigrade/Notification/UnfollowNotif.php | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Digitigrade/Notification/UnfollowNotif.php (limited to 'Digitigrade/Notification/UnfollowNotif.php') diff --git a/Digitigrade/Notification/UnfollowNotif.php b/Digitigrade/Notification/UnfollowNotif.php new file mode 100644 index 0000000..e00c342 --- /dev/null +++ b/Digitigrade/Notification/UnfollowNotif.php @@ -0,0 +1,49 @@ +subject = $subject; + $this->object = $object; + } + + public function toJsonReference(): mixed { + return [$this->subject->id, $this->object->id]; + } + + public static function fromJsonReference(mixed $reference): self { + return new self( + Actor::find($reference[0]), + Actor::find($reference[1]) + ); + } + + public function getNotificationTitle(): string { + return sprintf(__('notifications.follow.removed'), $this->subject->displayName); + } + public function getNotificationTitleLink(): ?string { + return '/@/' . $this->subject->getFullHandle(); + } + public function getNotificationImageUrl(): ?string { + return $this->subject->avatar ?? '/static/default-avatar.png'; + } + public function getNotificationImageLink(): ?string { + return $this->getNotificationTitleLink(); + } + public function getNotificationBody(): ?string { + return null; + } + + public function processNotifications() { + if (!$this->object->isLocal) + return; + Notification::fromNotifyable($this, UserAccount::findByLinkedActor($this->object))->send(); + } +} \ No newline at end of file -- cgit v1.3