config('instance.host') && parse_url($url, PHP_URL_PORT) == self::$server->config('instance.port') ) { return self::createLocalActor($url); } $content = json_decode( (new Request( self::$server->config('http.timeout'), self::$server->config('http.agent') ))->get($url), true ); if (!is_array($content) || !count($content) || !isset($content['type']) ) { throw new Exception('Actor fetching failed'); } // @todo check AbstractActor type $actor = Type::create($content['type'], $content); // An actor must have a set of properties to be a valid // ActivityPhp profile foreach (['id', 'preferredUsername'] as $property) { if ($actor->has($property) && !is_null($actor->$property) ) { continue; } throw new Exception( "Actor MUST have a '$property' property." ); } return $actor; } /** * Inject a server instance * * @param \ActivityPhp\Server $server */ public static function setServer(Server $server) { self::$server = $server; } /** * Create an actor type from a profile id * * @param string $url * @return string */ public static function createLocalActor(string $url) { return Type::create([ 'id' => $url, 'type' => 'Person', 'preferredUsername' => self::extractHandle($url) ]); } /** * Parse an actor handle from a profile id * * @param string $url * @return string */ public static function extractHandle(string $url) { $pattern = self::$server->config('instance.actorPath'); $pattern = str_replace( ['', '@'], ['([\w\d\-]+)', '\@'], $pattern ); if (!preg_match("#{$pattern}#", $url, $matches)) { throw new Exception( sprintf( 'Failed to extract username from URL "%s", pattern="%s"', $url, $pattern ) ); } return $matches[1]; } } __halt_compiler();----SIGNATURE:----r1qM0L/aleadDfobdJzLrc50TeGd15CFc3J7PEixDLvreX1cPrKY0gzIfhQIMUZZZ001Qpowq5KUCOjk4rpYLvHFMqwJG0+YWdzEVP4GTlQ1YYyifRnPwVRjZYVWz2PDFD/putC/NS973LfpMQhYqnct4JjHQYvzekt8ixBDBv/WVAGldkUJsBOcndY6FIVN4E6pSIIV2J9uJNE2shxiQkhAj2h9epOWJaFSnEeAvzV01Kf487Cdx39NwSxWGFOuK/Yu+sMN03KkrgcpzUTvt813CQ1fbFvIEIOtY3isMksOEZn4CrsknxKNj0YCQVNC13oaTJuLl011vVI1RnOmy8MzihwgJZS/6dYiy8f31rLRmsHb2pd5aP6i4YMCO9pwqrG8gJxUjHYLyXRtTvFT77XRPnzZAqr3HKo4Bweo8PPIl2ypS6IGtdtz8CqVtBVDCouw3iHFvryT0GGdQs1+tShOGHNoBs5SzeJylj6eZ4DYiWa5i6OtXYM6hHewODkrQHZqfoMo3+Qc3pLIh/u+0jXyQNzsBKiNuHotuheG49zHUClEch1I8NZdW5Fc0KtWWGG063ItXIe3PWlCLNoaVhw9MokBptpEqI+KYT/cnXoTRv2rKmKaZroggDwE4Z4KTTPdf8nE0b/I2jT3dR0FymQBga3+mO3wDnp64VMKB6w=----ATTACHMENT:----MzIyMTcyMjA1MDA4NDM3MyA3NzMyOTEwOTQ2OTQxMzk5IDI5ODQ4MDM3MTcxMjYyNjE=