Reverted yesterdays panic coding
This commit is contained in:
parent
ce6b4c27ea
commit
cb7206d92f
1 changed files with 27 additions and 25 deletions
|
@ -165,7 +165,8 @@ class APContact
|
||||||
return $fetched_contact;
|
return $fetched_contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($data['id'])) {
|
$compacted = JsonLD::compact($data);
|
||||||
|
if (empty($compacted['@id'])) {
|
||||||
return $fetched_contact;
|
return $fetched_contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,39 +180,40 @@ class APContact
|
||||||
DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
|
DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
$apcontact['url'] = $data['id'];
|
$apcontact['url'] = $compacted['@id'];
|
||||||
$apcontact['uuid'] = JsonLD::fetchElement($data, 'diaspora:guid');
|
$apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
|
||||||
$apcontact['type'] = JsonLD::fetchElement($data, 'type');
|
$apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
|
||||||
$apcontact['following'] = JsonLD::fetchElement($data, 'following');
|
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
|
||||||
$apcontact['followers'] = JsonLD::fetchElement($data, 'followers');
|
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
|
||||||
$apcontact['inbox'] = JsonLD::fetchElement($data, 'inbox');
|
$apcontact['inbox'] = JsonLD::fetchElement($compacted, 'ldp:inbox', '@id');
|
||||||
self::unarchiveInbox($apcontact['inbox'], false);
|
self::unarchiveInbox($apcontact['inbox'], false);
|
||||||
$apcontact['outbox'] = JsonLD::fetchElement($data, 'outbox');
|
|
||||||
|
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
|
||||||
|
|
||||||
$apcontact['sharedinbox'] = '';
|
$apcontact['sharedinbox'] = '';
|
||||||
if (!empty($data['endpoints'])) {
|
if (!empty($compacted['as:endpoints'])) {
|
||||||
$apcontact['sharedinbox'] = JsonLD::fetchElement($data['endpoints'], 'sharedInbox');
|
$apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedbox', '@id');
|
||||||
self::unarchiveInbox($apcontact['sharedinbox'], true);
|
self::unarchiveInbox($apcontact['sharedinbox'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$apcontact['nick'] = JsonLD::fetchElement($data, 'preferredUsername') ?? '';
|
$apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername', '@value') ?? '';
|
||||||
$apcontact['name'] = JsonLD::fetchElement($data, 'name');
|
$apcontact['name'] = JsonLD::fetchElement($compacted, 'as:name', '@value');
|
||||||
|
|
||||||
if (empty($apcontact['name'])) {
|
if (empty($apcontact['name'])) {
|
||||||
$apcontact['name'] = $apcontact['nick'];
|
$apcontact['name'] = $apcontact['nick'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($data, 'summary'));
|
$apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary', '@value'));
|
||||||
|
|
||||||
$apcontact['photo'] = JsonLD::fetchElement($data, 'icon');
|
$apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
|
||||||
if (is_array($apcontact['photo']) || !empty($data['icon']['url'])) {
|
if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
|
||||||
$apcontact['photo'] = JsonLD::fetchElement($data['icon'], 'url');
|
$apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($apcontact['alias'])) {
|
if (empty($apcontact['alias'])) {
|
||||||
$apcontact['alias'] = JsonLD::fetchElement($data, 'url');
|
$apcontact['alias'] = JsonLD::fetchElement($compacted, 'as:url', '@id');
|
||||||
if (is_array($apcontact['alias'])) {
|
if (is_array($apcontact['alias'])) {
|
||||||
$apcontact['alias'] = JsonLD::fetchElement($data['url'], 'href');
|
$apcontact['alias'] = JsonLD::fetchElement($compacted['as:url'], 'as:href', '@id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,18 +243,18 @@ class APContact
|
||||||
}
|
}
|
||||||
|
|
||||||
$apcontact['pubkey'] = null;
|
$apcontact['pubkey'] = null;
|
||||||
if (!empty($data['publicKey'])) {
|
if (!empty($compacted['w3id:publicKey'])) {
|
||||||
$apcontact['pubkey'] = trim(JsonLD::fetchElement($data['publicKey'], 'publicKeyPem'));
|
$apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value'));
|
||||||
if (strstr($apcontact['pubkey'], 'RSA ')) {
|
if (strstr($apcontact['pubkey'], 'RSA ')) {
|
||||||
$apcontact['pubkey'] = Crypto::rsaToPem($apcontact['pubkey']);
|
$apcontact['pubkey'] = Crypto::rsaToPem($apcontact['pubkey']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$apcontact['manually-approve'] = (int)JsonLD::fetchElement($data, 'manuallyApprovesFollowers');
|
$apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
|
||||||
|
|
||||||
if (!empty($data['generator'])) {
|
if (!empty($compacted['as:generator'])) {
|
||||||
$apcontact['baseurl'] = JsonLD::fetchElement($data['generator'], 'url');
|
$apcontact['baseurl'] = JsonLD::fetchElement($compacted['as:generator'], 'as:url', '@id');
|
||||||
$apcontact['generator'] = JsonLD::fetchElement($data['generator'], 'name');
|
$apcontact['generator'] = JsonLD::fetchElement($compacted['as:generator'], 'as:name', '@value');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($apcontact['following'])) {
|
if (!empty($apcontact['following'])) {
|
||||||
|
|
Loading…
Reference in a new issue