aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Model/Note.php
diff options
context:
space:
mode:
Diffstat (limited to 'Digitigrade/Model/Note.php')
-rw-r--r--Digitigrade/Model/Note.php32
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) {