diff options
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 |
