diff options
| author | winter | 2024-12-09 21:31:54 +0000 |
|---|---|---|
| committer | winter | 2024-12-09 21:31:54 +0000 |
| commit | 4c7bde1400820f36caf8b2a5374007384c3018f3 (patch) | |
| tree | 83ed26ff368117b8e392f7bc28736482077fc2f4 /Digitigrade/Model/NotePrivacy.php | |
| parent | 50edbd3907c26a2d4d616421de9bb51a4d083c1b (diff) | |
rename to Digitigrade / PawPub
:3
Diffstat (limited to 'Digitigrade/Model/NotePrivacy.php')
| -rw-r--r-- | Digitigrade/Model/NotePrivacy.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Digitigrade/Model/NotePrivacy.php b/Digitigrade/Model/NotePrivacy.php new file mode 100644 index 0000000..faaacf6 --- /dev/null +++ b/Digitigrade/Model/NotePrivacy.php @@ -0,0 +1,39 @@ +<?php +namespace Digitigrade\Model; + +use Digitigrade\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 + ]; + } +}
\ No newline at end of file |
