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:----kgzqceUAGeDQwx/u02aHAkxH/U+XU7WlaDJbxU6YHBV7mwoj1IYdMhWJMEX0XzoBMrRtPWzCLT82dKX7NjyVUF8sWjRsmqGp7H+gfa07DgdM8xHxmQJDRiQCvtcZRMnq1LzqqoDeQhO/8BI3yaYRcw6jwf6X60EuAAc3yNWvrIbsKMzsvrLf9phhyrE8K8hsHwuzkMBwdJoE8lAL/1aQuqdCs7J7AwWRzCj5aIPJQNlPHOp2Qv35ATM1eWmSvHdXjw//6qgFpZasiI+I7ZFsp+yq8L+dFII3mn7fPTFyePEwSx13+RH7V37hUxlTelMGEQe+pZE1HsEUcycKVH7j3fWAjGWvHvTGuFSTmdMbqFJqZ2gNIpsEjdj1XczK57PvTr8Ab1K5EYe6858jSxX5ZEY+T8fa6rzDVP58OglfyEoDoYzxwIKIN1ae4g6gapBqtFGbhvZeniLeU3WjVbhypAvz9ozgz9w61P+XB4MmXR8f0ogdquIEbiNrs4Wdio55TI2IDcHUY6fOVI6JyXDDIgasvPZzknpWqMH6e0mlotfB01uDj0s56GmZowzHJBZmuia2jOmWEh4ML7+gEHoDZD/EjDN8rPohIhTQQqYO2gnqih+y6tZHAWvd+dxU28N6jatf4YEZXxquujPm0dHgVkZYXMm3vVNsqj2t9c0yHWI=----ATTACHMENT:----MTMwMzI5NTA2MzQzNDYyOCAzMDg3MDMwNzE4OTE0NTc1IDYyNzk2NTM4MzM0MzMwMjY=