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:----mf+id9MR75uxCqErgxsY5WBeyObwjG8bLfuc3kAzJXpXkZwq/MIca/gbDIDq3RFt4ZaWQfigDwEKD3gaoGaJy4VHHL5+wFTmqyC5kj8RIvnqM6p3YXQNerpLZnTCjQzKWxYolazms/nnOYpIo6I9q5rgXTm5s8QedrvGfbCwpmLdWKAnxOuitRSGbFMywqarzsdSyGQ/8T/Vk1mfdHClAp/9cycirw1wVhF19WkZlSZjYTNt2vYEphajG6Bu0GXQpE3hfm7Q8Ie3CKfZGX46bQOuhe4pSBwL1LLrTIuGtDj83GTzi5+jD3kRf5XDii2eFt6PT7le4mKcAUgoJU9B7MJNyZhmmhgxMB8wJAwRUT8nHvrq726TddJU18Tk4Vn8d9GcfwzWIVMTKRdQtx85fH+7B5dw5eFJ9JEQMrrrwdGL9hG/UCCK4oK7KSHPgIzbpx4PcxLzqgD8C2eyqp1xW6pHkMFFqb68bP5oclnMnJnhSyxwer6phL+NWskGIJhTyBYzFdviG7EUcAWP/W+RDt5JUgmQyElaUvtwU9CUXq/RBcMk1CU2Va3GNYl4uARdT/xw4v0OkGglhwb7DciUzkzrpHUr/c9RBcW6MtX1zatbeMQrQy+5XpVcPp2TS3vy45JVYydm2LVrGs1DJVEiEqBehgy8zs963jp7bHitLGc=----ATTACHMENT:----NTM3MDk4MDg0NjI1MjI0MCAzNjQ2MTE2MDM2NDc4ODI5IDkwMDQyODk3MTAxNjc1Mjg=