blob: e00c342e2d62fa114803051c4a9ad0dc2830a0b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
namespace Digitigrade\Notification;
use Digitigrade\Model\Actor;
use Digitigrade\Model\Notification;
use Digitigrade\Model\UserAccount;
class UnfollowNotif implements Notifyable {
private Actor $subject;
private Actor $object;
public function __construct(Actor $subject, Actor $object) {
$this->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();
}
}
|