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:----sO+I8uBaDBR7vD1r3OLDvU2s82o87M9YNKcl4DzH1xP8fj7lSttaSGgxkhV0/a2VXQq0hDoYG63u54ufO8yged/s+dg5nw3t8zL73DDFVbG9SwKUOAEDc/cPCKLhpy9h40O/trBFrk972j5cLb2Etk1YVK+BewOtMnR6ewKn5hZmJg2xHUSxipo0dkFEte8zz1KPLzEfC79+pvTb7kf8AFHbb8BjZMw+uLWpU8ALBvJ93Nyr7uJfWgVJzMkaR8XxlupCYUwkR5wpHsEf2tV+wcd+RVINa0msFi7cssoRQXObtgc5x3OtJoneMUosULNIGTGxM2vCTtN64TNckXG+XOxDX63KDff/5vcJtdv+XwNIgQU3OCo8T7nwBnrEyNmecVZS3hCYbutdsm2hrM3rnAknIWyT9roWwUnyHbN8hJ3tCtMw6NGOT9kD+ldlgCFiVsDJee7474jhr1c9a6izpMs79awO3fepprY/wUz/SDbE1zJyTZId+NMiTF3Ot29jOdtuCfFe2C5K4HAtUx/EoAJez8C8PavG/2zudG7s0tSc2RIsfUSq7Kcs8OP+Gf9vzKMa3QTlg1VDh0Q8qvsZCTsN4t+gN5t4z3Zllb7fzZbQ4X0NIYSlsOGmxiCgvEHC8Ac5YMfqCCOOuelyY5QEJ3lAbqSGkoxspbqcAWMAR9U=----ATTACHMENT:----MTA4NDE2OTYwODM5NjA4MSA4MjUxMzQ4Mzk5ODMyMzg2IDcxNzE0MDgxOTAyODE4NzE=