Update AP Helpers

This commit is contained in:
Daniel Supernault 2018-12-24 21:29:16 -07:00
parent 154a6444e2
commit 2147c215d2
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -281,11 +281,11 @@ class Helpers {
public static function profileFirstOrNew($url, $runJobs = false) public static function profileFirstOrNew($url, $runJobs = false)
{ {
$res = self::fetchProfileFromUrl($url); $res = self::fetchProfileFromUrl($url);
$domain = parse_url($res['url'], PHP_URL_HOST); $domain = parse_url($res['id'], PHP_URL_HOST);
$username = $res['preferredUsername']; $username = $res['preferredUsername'];
$remoteUsername = "@{$username}@{$domain}"; $remoteUsername = "@{$username}@{$domain}";
$profile = Profile::whereRemoteUrl($res['url'])->first(); $profile = Profile::whereRemoteUrl($res['id'])->first();
if(!$profile) { if(!$profile) {
$profile = new Profile; $profile = new Profile;
$profile->domain = $domain; $profile->domain = $domain;
@ -295,7 +295,7 @@ class Helpers {
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null; $profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
$profile->inbox_url = $res['inbox']; $profile->inbox_url = $res['inbox'];
$profile->outbox_url = $res['outbox']; $profile->outbox_url = $res['outbox'];
$profile->remote_url = $res['url']; $profile->remote_url = $res['id'];
$profile->public_key = $res['publicKey']['publicKeyPem']; $profile->public_key = $res['publicKey']['publicKeyPem'];
$profile->key_id = $res['publicKey']['id']; $profile->key_id = $res['publicKey']['id'];
$profile->save(); $profile->save();