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:----Ec+cIf9r449SdT0vI3lF7T6odmTZDsfgoZ1AR/4OZVda7eOQj05r7NbrNbvtgyVPgKHDjpotL7rk9XvEBN4YpQ+pzzRzSaFHv+r6xW8UgeZhggePvxwvj1/s9KxUuFlzNXcZHq3uYl2Gpqe5Ox7XDugB2BfJRUY75K4mTOBSZgAri/+RDAPcWKwbTvlGxaOm2F+07NadXhAw5wCZxbxyppj5g2Mgo0NTvUsl3oECA/VIZTqzA36UQOFJt6jbuFbghekvPjXB0wrnNvqKFMTZQMX0MwINCLYa4j997ua4ANWl1SgMxbcYuTQU0bs/Sl3b05TXzogW1kuZVPqm4fmC8znVqlkYe1NcUqRqj9LVh1plICp9BPWddHBwfqIoyzHuPgXct0n8iPT+x+CLCYrDN0INUi0EsTcUGwnxXyiGSwwXYfhGJaLpf6rEvGLXOxwWua6O6UX0tb06v5vQIsnSzknyfDX4hPD2ee4wHsA8Z+QbrDbhquFXGkR10qWCydovJlcyT6hg39hI5FjrZb72kgYhKeeVSSIWixxlRWgpcjor4/oVYdNVeiKjXHrfq1J6w6o2ZKQBi828BdaK/6P2dBEZNQ6IhBvvgkbdSNJ1oLM6VdYWXPwqQGqU/+7CLatYcIFVjA/P7MP3Zx12MnQ429uISm7IVYtVN7kGSoDUDcQ=----ATTACHMENT:----NTU1OTY2NjA1OTQ0MDMzOCA5ODk3NTI2Mzk0Mzk4OTQ0IDU5ODI1MzY1NzAwMzEwODE=