mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-18 11:03:17 +00:00
Update AP helpers, fix Moved account support
This commit is contained in:
parent
d0c376f579
commit
f1497655ba
1 changed files with 16 additions and 8 deletions
|
@ -801,12 +801,19 @@ class Helpers
|
|||
return self::profileUpdateOrCreate($url);
|
||||
}
|
||||
|
||||
public static function profileUpdateOrCreate($url)
|
||||
public static function profileUpdateOrCreate($url, $movedToCheck = false)
|
||||
{
|
||||
$movedToPid = null;
|
||||
$res = self::fetchProfileFromUrl($url);
|
||||
if (! $res || isset($res['id']) == false) {
|
||||
return;
|
||||
}
|
||||
if (! self::validateUrl($res['inbox'])) {
|
||||
return;
|
||||
}
|
||||
if (! self::validateUrl($res['id'])) {
|
||||
return;
|
||||
}
|
||||
$urlDomain = parse_url($url, PHP_URL_HOST);
|
||||
$domain = parse_url($res['id'], PHP_URL_HOST);
|
||||
if (strtolower($urlDomain) !== strtolower($domain)) {
|
||||
|
@ -829,13 +836,6 @@ class Helpers
|
|||
$remoteUsername = $username;
|
||||
$webfinger = "@{$username}@{$domain}";
|
||||
|
||||
if (! self::validateUrl($res['inbox'])) {
|
||||
return;
|
||||
}
|
||||
if (! self::validateUrl($res['id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$instance = Instance::updateOrCreate([
|
||||
'domain' => $domain,
|
||||
]);
|
||||
|
@ -843,6 +843,13 @@ class Helpers
|
|||
\App\Jobs\InstancePipeline\FetchNodeinfoPipeline::dispatch($instance)->onQueue('low');
|
||||
}
|
||||
|
||||
if (! $movedToCheck && isset($res['movedTo']) && Helpers::validateUrl($res['movedTo'])) {
|
||||
$movedTo = self::profileUpdateOrCreate($res['movedTo'], true);
|
||||
if ($movedTo) {
|
||||
$movedToPid = $movedTo->id;
|
||||
}
|
||||
}
|
||||
|
||||
$profile = Profile::updateOrCreate(
|
||||
[
|
||||
'domain' => strtolower($domain),
|
||||
|
@ -859,6 +866,7 @@ class Helpers
|
|||
'outbox_url' => isset($res['outbox']) ? $res['outbox'] : null,
|
||||
'public_key' => $res['publicKey']['publicKeyPem'],
|
||||
'indexable' => isset($res['indexable']) && is_bool($res['indexable']) ? $res['indexable'] : false,
|
||||
'moved_to_profile_id' => $movedToPid,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue