aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Notification/UnblockNotif.php
blob: 7f7ac649df9ec033cf47088e0c57f3d9a949a47f (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 UnblockNotif 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.unblock'), $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();
    }
}