mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-17 20:11:27 +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);
|
return self::profileUpdateOrCreate($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function profileUpdateOrCreate($url)
|
public static function profileUpdateOrCreate($url, $movedToCheck = false)
|
||||||
{
|
{
|
||||||
|
$movedToPid = null;
|
||||||
$res = self::fetchProfileFromUrl($url);
|
$res = self::fetchProfileFromUrl($url);
|
||||||
if (! $res || isset($res['id']) == false) {
|
if (! $res || isset($res['id']) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (! self::validateUrl($res['inbox'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! self::validateUrl($res['id'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$urlDomain = parse_url($url, PHP_URL_HOST);
|
$urlDomain = parse_url($url, PHP_URL_HOST);
|
||||||
$domain = parse_url($res['id'], PHP_URL_HOST);
|
$domain = parse_url($res['id'], PHP_URL_HOST);
|
||||||
if (strtolower($urlDomain) !== strtolower($domain)) {
|
if (strtolower($urlDomain) !== strtolower($domain)) {
|
||||||
|
@ -829,13 +836,6 @@ class Helpers
|
||||||
$remoteUsername = $username;
|
$remoteUsername = $username;
|
||||||
$webfinger = "@{$username}@{$domain}";
|
$webfinger = "@{$username}@{$domain}";
|
||||||
|
|
||||||
if (! self::validateUrl($res['inbox'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (! self::validateUrl($res['id'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$instance = Instance::updateOrCreate([
|
$instance = Instance::updateOrCreate([
|
||||||
'domain' => $domain,
|
'domain' => $domain,
|
||||||
]);
|
]);
|
||||||
|
@ -843,6 +843,13 @@ class Helpers
|
||||||
\App\Jobs\InstancePipeline\FetchNodeinfoPipeline::dispatch($instance)->onQueue('low');
|
\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(
|
$profile = Profile::updateOrCreate(
|
||||||
[
|
[
|
||||||
'domain' => strtolower($domain),
|
'domain' => strtolower($domain),
|
||||||
|
@ -859,6 +866,7 @@ class Helpers
|
||||||
'outbox_url' => isset($res['outbox']) ? $res['outbox'] : null,
|
'outbox_url' => isset($res['outbox']) ? $res['outbox'] : null,
|
||||||
'public_key' => $res['publicKey']['publicKeyPem'],
|
'public_key' => $res['publicKey']['publicKeyPem'],
|
||||||
'indexable' => isset($res['indexable']) && is_bool($res['indexable']) ? $res['indexable'] : false,
|
'indexable' => isset($res['indexable']) && is_bool($res['indexable']) ? $res['indexable'] : false,
|
||||||
|
'moved_to_profile_id' => $movedToPid,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue