From 503a49b7d7b4275fd09b4a7c06cbdbdf257fef79 Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 24 Dec 2024 14:15:02 +0000 Subject: breaking change: use id in actor uri instead of handle --- Digitigrade/Model/Actor.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'Digitigrade') diff --git a/Digitigrade/Model/Actor.php b/Digitigrade/Model/Actor.php index 3ad0efe..46c6f9a 100644 --- a/Digitigrade/Model/Actor.php +++ b/Digitigrade/Model/Actor.php @@ -41,7 +41,7 @@ class Actor extends PushableModel implements RpcReceiver { throw new \RuntimeException('an actor with that local handle already exists!'); } $actor = new self(); - $actor->uri = path_to_uri("/actor/$handle"); + $actor->uri = "UNKNOWN"; // need to know the id first $actor->isLocal = true; $date = new \DateTimeImmutable(); $actor->created = $date; @@ -56,8 +56,12 @@ class Actor extends PushableModel implements RpcReceiver { // don't actually need to set these either // just need to set the basicFeed since it's a required field $actor->endpoints = new ActorEndpoints(); - $actor->endpoints->basicFeed = path_to_uri("/actor/$handle/basicFeed"); + $actor->endpoints->basicFeed = "UNKNOWN"; + + $actor->save(); + $actor->uri = path_to_uri("/actor/$actor->id"); $actor->save(); + return $actor; } @@ -212,13 +216,13 @@ class Actor extends PushableModel implements RpcReceiver { if ($this->deleted) { return [ 'type' => 'tombstone', - 'self' => path_to_uri("/actor/$this->handle"), + 'self' => path_to_uri("/actor/$this->id"), 'previousType' => 'actor' ]; } return [ 'type' => 'actor', - 'self' => path_to_uri("/actor/$this->handle"), + 'self' => path_to_uri("/actor/$this->id"), 'created' => $this->created?->format('c'), 'modified' => $this->modified?->format('c'), 'homepage' => path_to_uri("/@/$this->handle"), @@ -230,12 +234,12 @@ class Actor extends PushableModel implements RpcReceiver { 'automated' => $this->automated, 'requestToFollow' => $this->requestToFollow, 'endpoints' => [ - 'basicFeed' => path_to_uri("/actor/$this->handle/basicFeed"), - 'fullFeed' => path_to_uri("/actor/$this->handle/fullFeed"), - 'follow' => path_to_uri("/actor/$this->handle/follow"), - 'unfollow' => path_to_uri("/actor/$this->handle/unfollow"), - 'acceptedFollow' => path_to_uri("/actor/$this->handle/acceptedFollow"), - 'rejectedFollow' => path_to_uri("/actor/$this->handle/rejectedFollow"), + 'basicFeed' => path_to_uri("/actor/$this->id/basicFeed"), + 'fullFeed' => path_to_uri("/actor/$this->id/fullFeed"), + 'follow' => path_to_uri("/actor/$this->id/follow"), + 'unfollow' => path_to_uri("/actor/$this->id/unfollow"), + 'acceptedFollow' => path_to_uri("/actor/$this->id/acceptedFollow"), + 'rejectedFollow' => path_to_uri("/actor/$this->id/rejectedFollow"), ] ]; } -- cgit v1.3