From bda28640d6e066ae338c6f31407df274ed09f026 Mon Sep 17 00:00:00 2001 From: winter Date: Sun, 8 Dec 2024 23:18:35 +0000 Subject: implement remote object fetching! this is most of the tricky parts of inbound federation :3 --- WpfTest/Model/NotePrivacy.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'WpfTest/Model/NotePrivacy.php') 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 -- cgit v1.3