mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-27 15:00:45 +00:00
Update AP helpers
This commit is contained in:
parent
afb5ea18e5
commit
58d3c700b2
1 changed files with 18 additions and 21 deletions
|
@ -667,7 +667,7 @@ class Helpers {
|
||||||
}
|
}
|
||||||
$hash = base64_encode($url);
|
$hash = base64_encode($url);
|
||||||
$key = 'ap:profile:by_url:' . $hash;
|
$key = 'ap:profile:by_url:' . $hash;
|
||||||
$ttl = now()->addMinutes(5);
|
$ttl = now()->addSeconds(60);
|
||||||
$profile = Cache::remember($key, $ttl, function() use($url, $runJobs) {
|
$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;
|
||||||
|
@ -706,26 +706,23 @@ class Helpers {
|
||||||
if($instance->wasRecentlyCreated == true) {
|
if($instance->wasRecentlyCreated == true) {
|
||||||
\App\Jobs\InstancePipeline\FetchNodeinfoPipeline::dispatch($instance)->onQueue('low');
|
\App\Jobs\InstancePipeline\FetchNodeinfoPipeline::dispatch($instance)->onQueue('low');
|
||||||
}
|
}
|
||||||
$profileLockKey = 'helpers:profile-lock:' . hash('sha256', $res['id']);
|
$profile = DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
|
||||||
$profile = Cache::lock($profileLockKey)->get(function () use($domain, $webfinger, $res, $runJobs) {
|
$profile = new Profile();
|
||||||
return DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
|
$profile->domain = strtolower($domain);
|
||||||
$profile = new Profile();
|
$profile->username = Purify::clean($webfinger);
|
||||||
$profile->domain = strtolower($domain);
|
$profile->name = isset($res['name']) ? Purify::clean($res['name']) : 'user';
|
||||||
$profile->username = Purify::clean($webfinger);
|
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
||||||
$profile->name = isset($res['name']) ? Purify::clean($res['name']) : 'user';
|
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
||||||
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
$profile->inbox_url = $res['inbox'];
|
||||||
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
$profile->outbox_url = isset($res['outbox']) ? $res['outbox'] : null;
|
||||||
$profile->inbox_url = $res['inbox'];
|
$profile->remote_url = $res['id'];
|
||||||
$profile->outbox_url = isset($res['outbox']) ? $res['outbox'] : null;
|
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
||||||
$profile->remote_url = $res['id'];
|
$profile->key_id = $res['publicKey']['id'];
|
||||||
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
$profile->webfinger = Purify::clean($webfinger);
|
||||||
$profile->key_id = $res['publicKey']['id'];
|
$profile->last_fetched_at = now();
|
||||||
$profile->webfinger = Purify::clean($webfinger);
|
$profile->save();
|
||||||
$profile->last_fetched_at = now();
|
RemoteAvatarFetch::dispatch($profile);
|
||||||
$profile->save();
|
return $profile;
|
||||||
RemoteAvatarFetch::dispatch($profile);
|
|
||||||
return $profile;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Update info after 24 hours
|
// Update info after 24 hours
|
||||||
|
|
Loading…
Reference in a new issue