aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/Model/Note.php
diff options
context:
space:
mode:
authorwinter2024-12-08 23:18:35 +0000
committerwinter2024-12-08 23:18:35 +0000
commitbda28640d6e066ae338c6f31407df274ed09f026 (patch)
tree2a887dd4f98f79fc11efefc9585c58e144f66a00 /WpfTest/Model/Note.php
parentb00185ddbac9ac3de975a3954f2ede2f24458f6a (diff)
implement remote object fetching!
this is most of the tricky parts of inbound federation :3
Diffstat (limited to 'WpfTest/Model/Note.php')
-rw-r--r--WpfTest/Model/Note.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/WpfTest/Model/Note.php b/WpfTest/Model/Note.php
index 85b3567..af2d2aa 100644
--- a/WpfTest/Model/Note.php
+++ b/WpfTest/Model/Note.php
@@ -2,9 +2,8 @@
namespace WpfTest\Model;
use WpfTest\Db;
-use WpfTest\Model;
-class Note extends Model implements \JsonSerializable {
+class Note extends FetchableModel implements \JsonSerializable {
public ?int $id;
public string $uri;
public \DateTimeImmutable $created;
@@ -30,7 +29,15 @@ class Note extends Model implements \JsonSerializable {
public array $attachments = [];
public array $extensions = [];
- protected function hydrate(array $row) {
+ protected function getUpdateWhereClause(\PDO $db): ?string {
+ if (self::findWhere('uri = ?', [$this->uri]) != null)
+ return 'uri = ' . $db->quote($this->uri);
+ if (self::findWhere('id = ?', [$this->id]) != null)
+ return "id = $this->id";
+ return null;
+ }
+
+ protected function hydrate() {
$this->privacy = NotePrivacy::findWhere('note_id = ?', [$this->id]);
$this->formattedContent = $this->findFormattedContents();
$this->mentions = $this->findMentions();
@@ -74,14 +81,7 @@ class Note extends Model implements \JsonSerializable {
}, $this->mentions),
'inReplyTo' => $this->inReplyTo?->uri,
'threadApex' => $this->threadApex?->uri,
- 'privacy' => [
- 'scope' => $this->privacy->scope->name,
- 'alsoVisibleTo' => $this->privacy->alsoVisibleTo,
- 'indexable' => $this->privacy->indexable,
- 'canReshare' => $this->privacy->canReshare->name,
- 'canReply' => $this->privacy->canReply->name,
- 'canOtherInteract' => $this->privacy->canOtherInteract->name
- ],
+ 'privacy' => $this->privacy,
'attachments' => array_map(function (NoteAttachment $attachment) {
return [
'type' => $attachment->type,