diff options
Diffstat (limited to 'WpfTest/Model/NotePrivacy.php')
| -rw-r--r-- | WpfTest/Model/NotePrivacy.php | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/WpfTest/Model/NotePrivacy.php b/WpfTest/Model/NotePrivacy.php index b7ed58a..b955447 100644 --- a/WpfTest/Model/NotePrivacy.php +++ b/WpfTest/Model/NotePrivacy.php @@ -3,14 +3,37 @@ namespace WpfTest\Model; use WpfTest\Model; -class NotePrivacy extends 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; + 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 |
