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:----vr9D0khK/fMBu38Gyuk9bJEmQf2EFr042BwVqHlXTMhrUgFDrdhGxiqIgs6CmhPQAn2lTjtokKechgkg9cTHw15ZjBJXGQlYo2xrb9io1bdhVwSA8iP8odVDUpX2k2HWYS+nuSzdwKyyyI0EHuSzrbLetM4ugQBhRJPYN21ik2arb7tsIpujfcQ0rDzpoOa3EIZt93CzBTx3a+Gbk+rI2R9uXYjY0ECR8VxRybB5XIAa0P7Gbd3L0i+mHs2kxKsTLkXop30DsNa6ekoQBT7fb5qGpxJkMqgaH085cOTA2uP+vD4MoUr31A4Q4SxngfVTd4A4nioeCnHlgwl9o9FXJIThdHJJJuNJojR+6FSYhXDEW0rH4gBoby0OdkW2/SwvBDLuTyGRMtNb2lsOguQhUjlMu0mAuLh4qQjeOC0eKaOz1vHfutA3QKIkNdBACc9LWVxKNLyhiSMva3Aiu8oZLMz5zfM88NAVnsjqw10ehgPa7efMZv/7nD0hmv2Q4gyLfPJdREslD4wGKjJ8xKfa8I8+ExYFkYXfogoArDf4dgi1QHabNE4B98ls9eX2MwYkMf3UK9GYRUfz5fSwWFW78tasLTxy0Buud/bxuftiRZbOSRbrdNBypK4dIt91tEglcRf4bDHBJZXHnouBjm+YTZXZWBwptrVy0Lys+bnoD+I=----ATTACHMENT:----MjkwMzQ4NjAyNDA3MDQ3NSA5NjAzNjgyMjUxODM4OTYxIDE3NTE0ODMwODk1ODY3MTM=