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:----qhjB4YhvcrmuAjoISzzfUOiBL4AyiMPCE92EtY5zlJp9c7DdQIgtlAlylCsQs9MqoRC2WtK/JuaW8U/YpXlIWDdx/+VNqmPvtU9/YKZZXpZNLQyap4L76ob3h4OMfh7InYUZ5lBS0MAaGXMW0yY/g0hUgC2qZWdVxKR4VzO5tuZugKE1nmEG/Z+chPpS188YWsMtQoFEi6aRwkB6fvIheiw9kMxrb1eTQnFWGe/XMP5Vw0hJUXXWmw2cXAO9j4eo0Q6x1O6Qtlt+djJEsk09tt09k9iLtobQF5wgHNIN1XUmligriBEZhHU9SjOupPTzo8R7D5kgplxb6eNQCV8DlGpZnqV5IBPymqn3ABHgM6jXYzcsWxTiNSHtrl9eFDuGtra5LbNdfF40WkkN8BxPYZNUykeMNnQP9MJUMBWURFqBgbN8EO/iaSTHRqQlNpdjFvmPc7xjW+pkIW9Fo5bDcvefkxYeqp7O/NrQz6Ur6pGL45MAy2Aqbo9zgWun8fnCiizrOV5JK4mBMdE81wN6YvbiD9e79c4BLwBJSgcEYwEaRA/TZyD5gFW4KphdFR5a6i+TOKJ5JnvtuyzRXTjOLk+SFrNYmvL0fNvxyTs/kt4mkXToNRFp2gTB/sJnKmHTTLU2gY4ajVtkWRS9vl/yC54OkAF3pSVDM3k5iBUyALQ=----ATTACHMENT:----NDQyNDg1Mjg2OTc5NDU0MiA0MjgyMTk0ODUxMTMzODk5IDMxMTk5ODQ0OTc4MTUxODI=