aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/Model/Actor.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/Actor.php
parentb00185ddbac9ac3de975a3954f2ede2f24458f6a (diff)
implement remote object fetching!
this is most of the tricky parts of inbound federation :3
Diffstat (limited to 'WpfTest/Model/Actor.php')
-rw-r--r--WpfTest/Model/Actor.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/WpfTest/Model/Actor.php b/WpfTest/Model/Actor.php
index eaef99c..0b0e729 100644
--- a/WpfTest/Model/Actor.php
+++ b/WpfTest/Model/Actor.php
@@ -1,9 +1,9 @@
<?php
namespace WpfTest\Model;
-use WpfTest\Model;
+use WpfTest\RemoteFetchable;
-class Actor extends Model implements \JsonSerializable {
+class Actor extends FetchableModel implements \JsonSerializable {
public ?int $id;
public string $uri;
public bool $isLocal = false;
@@ -20,6 +20,14 @@ class Actor extends Model implements \JsonSerializable {
public ActorEndpoints $endpoints;
public array $extensions = [];
+ 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;
+ }
+
public static function findLocalByHandle(string $handle): ?self {
return self::findWhere('is_local = true AND handle = ?', [$handle]);
}
@@ -42,4 +50,8 @@ class Actor extends Model implements \JsonSerializable {
]
];
}
+
+ public function hydrate() {
+ $this->endpoints = ActorEndpoints::findWhere('actor_id = ?', [$this->id]);
+ }
} \ No newline at end of file