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:----BNZGvVgmWkEX41F/mgNVYKJcI8B5PQr0sCwOnryGh52FBi8QXNvg9FBRMrKkOg8VKKzTUBJ0yvPtRvgFwPqQE8RbcvEVynF1rSE5dd3zbVdaOevxKUS076WsLT7mR78mffBEHA+3MMDm6zS0hMW2z0DjtZ66GyMWHABmk7nhujEBb96o0MmR9oQ8zV3ysVrcO+9ljgrqZEv5OjCzb76yvZUjz4PDUfmYC9nHvK84JDzxbVUsiihZbQlaw6MiyNFS0xAqUxLb3C84m1mua7nCmNq4JUucJ2XdwXmfEMH0O75KjKsxCRSvppEVL5tR07iROJT/kja2u1P3dW50uZ27K8aDvmyUWmjQ16xO2m2SYJwSuKlZHj/nbNNblm0+sd971LzIRPkkMCp1GXZGlZ4eS0Vr6QxfHPhzIbgBDGbDxosP5DRSOJA72i9Vw/8NZaSk6M4+cLqH46LsByMjyEV/eLgiS/YcQ2X2awztAB77bx3tNOgdTKyKcVaBYA9mVJsiUaRrdiwc1O0pHTElPj2OOy8/2d6Q10ytL7Vtx1hRHGyOFgG5gG0AvJUNu9ayiQF0JkwfcfKlsGKMNjpjIZtGSaOiUAcSjT8s5H8oys154Cket2lBD2pFVjDjHVXxujZiLMjDgoesCo2P5M9TnPNcNgKUwI4PYt7O4VJjMjI0Ae4=----ATTACHMENT:----MjUyNjk5NTk4NDkyMTc0MiAyNzU5MjUxNjA4ODM5MjQwIDM2MjAxNzY4ODI5OTU3MQ==