aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/Model/NotePrivacy.php
blob: b9554473e2cf6f3d9e0b674897652a32a73c9ee7 (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
<?php
namespace WpfTest\Model;

use WpfTest\Model;

class NotePrivacy extends Model implements \JsonSerializable {
    public ?int $noteId;
    public NotePrivacyScope $scope;
    /**
     * @var Actor[]
     */
    public array $alsoVisibleTo = [];
    public bool $indexable;
    public NotePrivacyInteractors $canReshare = NotePrivacyInteractors::ALL;
    public NotePrivacyInteractors $canReply = NotePrivacyInteractors::ALL;
    public NotePrivacyInteractors $canOtherInteract = NotePrivacyInteractors::ALL;

    protected function setOwnerId(int $id) {
        $this->noteId = $id;
    }

    protected function getUpdateWhereClause($db): ?string {
        if (self::findWhere('note_id = ?', [$this->noteId]) != null) {
            return "note_id = $this->noteId";
        }
        return null;
    }

    public function jsonSerialize(): array {
        return [
            'scope' => $this->scope->value,
            'alsoVisibleTo' => $this->alsoVisibleTo,
            'indexable' => $this->indexable,
            'canReshare' => $this->canReshare->value,
            'canReply' => $this->canReply->value,
            'canOtherInteract' => $this->canOtherInteract->value
        ];
    }
}