|
|
@ -403,9 +403,13 @@ class Helpers {
|
|
|
|
public static function profileFirstOrNew($url, $runJobs = false)
|
|
|
|
public static function profileFirstOrNew($url, $runJobs = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$url = self::validateUrl($url);
|
|
|
|
$url = self::validateUrl($url);
|
|
|
|
if($url == false) {
|
|
|
|
if($url == false || strlen($url) > 190) {
|
|
|
|
abort(400, 'Invalid url');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$hash = base64_encode($url);
|
|
|
|
|
|
|
|
$key = 'ap:profile:by_url:' . $hash;
|
|
|
|
|
|
|
|
$ttl = now()->addMinutes(5);
|
|
|
|
|
|
|
|
$profile = Cache::remember($key, $ttl, function() use($url, $runJobs) {
|
|
|
|
$host = parse_url($url, PHP_URL_HOST);
|
|
|
|
$host = parse_url($url, PHP_URL_HOST);
|
|
|
|
$local = config('pixelfed.domain.app') == $host ? true : false;
|
|
|
|
$local = config('pixelfed.domain.app') == $host ? true : false;
|
|
|
|
|
|
|
|
|
|
|
@ -436,6 +440,7 @@ class Helpers {
|
|
|
|
|
|
|
|
|
|
|
|
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
|
|
|
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
|
|
|
if(!$profile) {
|
|
|
|
if(!$profile) {
|
|
|
|
|
|
|
|
$profile = DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
|
|
|
|
$profile = new Profile();
|
|
|
|
$profile = new Profile();
|
|
|
|
$profile->domain = strtolower($domain);
|
|
|
|
$profile->domain = strtolower($domain);
|
|
|
|
$profile->username = strtolower(Purify::clean($webfinger));
|
|
|
|
$profile->username = strtolower(Purify::clean($webfinger));
|
|
|
@ -454,6 +459,8 @@ class Helpers {
|
|
|
|
// RemoteFollowImportRecent::dispatch($res, $profile);
|
|
|
|
// RemoteFollowImportRecent::dispatch($res, $profile);
|
|
|
|
CreateAvatar::dispatch($profile);
|
|
|
|
CreateAvatar::dispatch($profile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $profile;
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Update info after 24 hours
|
|
|
|
// Update info after 24 hours
|
|
|
|
if($profile->last_fetched_at == null ||
|
|
|
|
if($profile->last_fetched_at == null ||
|
|
|
@ -467,6 +474,8 @@ class Helpers {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $profile;
|
|
|
|
return $profile;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return $profile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function profileFetch($url)
|
|
|
|
public static function profileFetch($url)
|
|
|
|