diff options
| author | winter | 2024-12-08 23:18:35 +0000 |
|---|---|---|
| committer | winter | 2024-12-08 23:18:35 +0000 |
| commit | bda28640d6e066ae338c6f31407df274ed09f026 (patch) | |
| tree | 2a887dd4f98f79fc11efefc9585c58e144f66a00 /WpfTest/Model/Actor.php | |
| parent | b00185ddbac9ac3de975a3954f2ede2f24458f6a (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.php | 16 |
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 |
