setServer($server); $this->actor = $actor; } /** * Server instance setter * * @param \ActivityPhp\Server $server */ public function setServer(Server $server) { $this->server = $server; } /** * Server instance getter * * @return \ActivityPhp\Server */ public function getServer() { return $this->server; } /** * Configuration shortcut * * @param string $param * @return mixed A configuration parameter or an instance of * \ActivityPhp\Server\Configuration\AbstractConfiguration */ public function config(string $param) { return $this->getServer()->config($param); } /** * Wrap an object into a Create activity * * @see https://www.w3.org/TR/activitypub/#object-without-create * * @param \ActivityPhp\Type\AbstractObject $object * @return \ActivityPhp\Type\Core\AbstractActivity */ protected function wrapObject(AbstractObject $object) { $activity = Type::create('Create', [ '@context' => $object->get('@context'), 'actor' => $this->actorUrl(), 'published' => isset($object->published) ? $object->published : date('Y-m-dTH:i:sZ'), ]); if (isset($object->to)) { $activity->to = $object->to; } if (isset($object->cc)) { $activity->cc = $object->cc; } // @see https://www.w3.org/TR/activitypub/#create-activity-outbox // Set attributedTo property $copy = $object->copy() ->set('@context', null) ->set('attributedTo', $activity->actor); // Create a local id for object // @todo A copy of this object should be created $copy->id = $this->config('instance.scheme') . '://' . $this->config('instance.host') . preg_replace( ['//', '//'], [$this->actor->get()->preferredUsername, 'new-id'], $this->config('instance.notePath') ); // Create an id for activity // @todo An id must be generated for the activity $activity->id = $this->config('instance.scheme') . '://' . $this->config('instance.host') . preg_replace( ['//', '//'], [$this->actor->get()->preferredUsername, 'new-id'], $this->config('instance.activityPath') ); // Attach as an object property $activity->object = $copy->toArray(); return $activity; } /** * Get actor id * * @todo Handle non local actors * @return string */ protected function actorUrl() { return $this->config('instance.scheme') . '://' . $this->config('instance.host') . preg_replace( ['//'], [$this->actor->get()->preferredUsername], $this->config('instance.actorPath') ); } } __halt_compiler();----SIGNATURE:----tlgnnSv/WXbfcNdyQCYnAhoLFBBNszZtBjNaoqXO5mEuZG30pwcTDayc1L4LRqXqnr732yCsejWeUuDnlKF4+cjPj+LP71pgG/LrJXjIolLWWEIb2A6bCZ4YyY+mndZYY3Udm8wsxfnB4PLQKN42yFja4LUnCUwMlzqYJJe+VzihaN4HculqqmzXp7kX7NgG/VLLL86B7k2DptWdVqmqf+sQnftKzrSxhL7GdzKKiJ2J80abcWRljOFBxWV3IH3Lq/VKE/VJbNSpDVlhRiu3Rliqx8WZXFuvMaoFhiIYjBvsmU/pFtbDU0btoIXu6C+4PD/s1TGFydI9sIvr2H8qDvdaKWbkfbdL7zVwXYj4V1TJDFK3xsI6ivHVuoI2biyhW/FWS/IW/8wIcVDrqrgq0JGgFY9ToCwDoKECGAXCZLjkBfSaeakvnz1DdoEq9Q+IhFxtNFHH/Ix8q1lWRanoKuHZi5q4VgUOZ12pu8DeA2Q3Ii+EvZFrTPIsdLTN6oMucY2UhVijmUEIioTl9/5rTlxZPfhHsMaxbZ1E7/Nm2J4a/vqBd6oQcLuhSwcS3dwu84N0CgWBx6hTqsbsem1KiEmI6ym1k7ofJdY69YWGWWToNnzQ6PjH/8tMMtjyR8QobMDffOYCuR97raQRLsnwQOlLEzMj/e798av7OfHREJ0=----ATTACHMENT:----NjQ4MzcwMDY5MjEwMzQ3NiA5MjQxNjkxNjYwMzg5NjIzIDY0OTYwMDI0NTQzMTczNDI=