From 8c6dad8c48d5d730b102d9de0079fee9752b0d35 Mon Sep 17 00:00:00 2001 From: winter Date: Sun, 19 Jan 2025 22:17:12 +0000 Subject: implement notifications --- Digitigrade/Model/Interaction.php | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'Digitigrade/Model/Interaction.php') diff --git a/Digitigrade/Model/Interaction.php b/Digitigrade/Model/Interaction.php index e5619bb..cf2be01 100644 --- a/Digitigrade/Model/Interaction.php +++ b/Digitigrade/Model/Interaction.php @@ -1,11 +1,12 @@ kind->value . '.title'), $this->author->displayName); + } + public function getNotificationTitleLink(): ?string { + return '/@/' . $this->target->author->getFullHandle() . '/note/' . $this->target->id; + } + public function getNotificationBody(): ?string { + return $this->target->plainContent; + } + public function getNotificationImageUrl(): ?string { + return $this->author->avatar; + } + public function getNotificationImageLink(): ?string { + return '/@/' . $this->author->getFullHandle(); + } + + public function toJsonReference(): mixed { + return $this->id; + } + + public static function fromJsonReference(mixed $reference): self { + return self::find($reference); + } + public function processTimelineAdditions() { // basically, if this is a reshare, we need to put a home timeline item // for all followers who can see the shared note @@ -80,6 +105,14 @@ class Interaction extends PushableModel { } } + public function processNotifications() { + if (!$this->target->author->isLocal || $this->author == $this->target->author) { + return; + } + $recipient = UserAccount::findByLinkedActor($this->target->author); + Notification::fromNotifyable($this, $recipient)->send(); + } + public function jsonSerialize(): array { if ($this->deleted) { return [ -- cgit v1.3