diff options
| author | winter | 2025-01-19 22:17:12 +0000 |
|---|---|---|
| committer | winter | 2025-01-19 22:17:12 +0000 |
| commit | 8c6dad8c48d5d730b102d9de0079fee9752b0d35 (patch) | |
| tree | 2cfe07a8c7958f78c767fd0d1444c3f8fef70511 /Digitigrade/Model/Note.php | |
| parent | 2d9bd87fb1c565ee161f93219ce2533e8dbffe06 (diff) | |
implement notifications
Diffstat (limited to 'Digitigrade/Model/Note.php')
| -rw-r--r-- | Digitigrade/Model/Note.php | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php index f6f492d..cf84ee0 100644 --- a/Digitigrade/Model/Note.php +++ b/Digitigrade/Model/Note.php @@ -2,11 +2,12 @@ namespace Digitigrade\Model; use Digitigrade\Db; -use Digitigrade\Timeline\HomeTimelineItem; +use Digitigrade\Model\HomeTimelineItem; +use Digitigrade\Notification\Notifyable; use Digitigrade\Timeline\TimelineIncludeable; use Digitigrade\Timeline\TimelineItem; -class Note extends PushableModel implements TimelineIncludeable { +class Note extends PushableModel implements TimelineIncludeable, Notifyable { public ?int $id; public string $uri; public \DateTimeImmutable $created; @@ -195,6 +196,33 @@ class Note extends PushableModel implements TimelineIncludeable { return self::find($reference); } + public function getNotificationTitle(): string { + // assuming that this notification is because the note is a reply for now + return sprintf(__('notifications.interaction.reply.title'), $this->author->displayName); + } + public function getNotificationTitleLink(): ?string { + return '/@/' . $this->author->getFullHandle() . '/note/' . $this->id; + } + public function getNotificationBody(): ?string { + return $this->plainContent; + } + public function getNotificationImageUrl(): ?string { + return $this->author->avatar; + } + public function getNotificationImageLink(): ?string { + return '/@/' . $this->author->getFullHandle(); + } + + public function processNotifications() { + foreach ($this->mentions as $a) { + if (!$a->isLocal) { + continue; + } + $user = UserAccount::findByLinkedActor($a); + Notification::fromNotifyable($this, $user)->send(); + } + } + public function processTimelineAdditions() { $item = new TimelineItem($this); foreach ($this->getRelevantActors() as $actor) { |
