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:----jzgAhDSvghYb7UoMlbnuec+P3n53YUeYqssJbqbllMjJwQrbrEu+QzdIzSrEZa9NZEEIfF3KitL1L7OT1LZfhDujG2+9DRncvaj6MRAR32a5PJmnc1gTBby+T16vJ0DCPAHdbV3XB+Is/6LT9R7WGXQxSurBRhnldun3DHfyXnvlsEbUHG9c+Ki8GS2raFOCf7Ppj9JwI42BZrQ6Q8kdF8fxEXe2w9kPj4obeu1bttxgDmYFn2blWJY4ME6P2JG8nwwWhGlNY4Pe48ZRFCFMkyR3UKTT0AV1USYI33qcZ6oIeApX2lSPd2znSUQtVb5CeH+scRA3sPaAZbWxloCXugPjaUP1a1Y7atpzqRc1yx1II6kW9EA0p9cOwXmZOACa+wCmhzQbWwfo9EQ/eDDn5/Fv1BhYMQ4Osx+cMxMPZqJnXXLJoqKWf6FUSeWKuPAMaWU1ToxA9714ZvYwvtPsRH1Ir7LFwqqNA1YAFOjQxLVqee+SQjbI/S9YIQfYUwhilL5GCGLnb8whcqjkyrSAKXFP4R827YZ2tlFC9xNX1stBZNaIXhsC5/0QXjqB6Wwl1PNfPmvo4CMlybzKq5n/uuAzIzHe5ZTGfwwLi/YMtvpMzbdFA5K9L4reNyWe06kKDPWBNcG2RhIR+n7qaPUX7pt4ANCFPUh6Vdw4bXIVC/Q=----ATTACHMENT:----OTgwMDA5NTUxODAxMDI5NSA5ODUyNjI2NzI4NjcwMjg4IDE0MDc4NjQyNDAxNDE2OTg=