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:----chqta4ydXwSNF+OmMajrTHS2jMqHPJYBR2JEBCRTfYJV4BCfkjb/0MWKw0TXZIF2CAjtEWgecYe6hk7w1iZgmATDKrZTJkOhf1UgmAUG/wLandrS7c5vvQwZOwLsrf0JBGN673DM4/td9OmPoAgYgFWUkdJbIAYZyFCjgN//mhHvXmPnUywP/Sd1i0wk+yOKK1xbM9/nsK04EPn/qayLZ1XJmCkarspY124qohOh75PiHFqUyI35zSEx//2xNxmo7Td1L+gnp4CcdHQv/PJLuuRDKIHm2WMl7T0tVdatLshAIzhvNDA733LG1EmYXaww8fiCQXV5Z/lELeC2lvUApJ8TuiqFcMpErEdbMWBryXJulqiYm3NiE/qC+vP5nsiHHocyP8jMQ+H1rTcPsiAx1fOYXn3aHMAxMCoDaU0AznKjxlXo33j1mHobz0noTxcPWHoCXudDxOA+HO3zRPJ2UycRuQqtNCMXdeYgXiisQKLjmFYnX+VanumX5xL8ipgbI+8zWLh7SHW3JwAONZ/Jg7T6boC2boNixvAfwO35NUq8+KR0RESEsehK7UJElIqXeXdX80mIrP+h4FUbvmHKiue6RGywQ8jK8VquCJ20ixAmVpfCmhO5zs0EPEWvW1YLidoormHqlSB+0wXDCiOeIYgYReFrYCtAFERT8Ure6YE=----ATTACHMENT:----NjE2NDI5MTY5Mjk2NjgwNyA5NzQ5MTUyODAxNTk1NjMzIDMxNjM1MDgwNDM4NTUzNDc=