From dfaa4b89c7f7fa2e196f1c9195c0de9d81c41619 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Jun 2023 04:34:06 +0000 Subject: [PATCH] Support for contact uri that aren't HTTP URLs --- src/Contact/Avatar.php | 8 ++++---- src/Model/Contact.php | 2 +- src/Model/Item.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index 299c263994..fc4b7e38cb 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -92,7 +92,7 @@ class Avatar return $fields; } - $filename = self::getFilename($contact['url']); + $filename = self::getFilename($contact['url'], $avatar); $timestamp = time(); $fields['blurhash'] = $image->getBlurHash(); @@ -120,7 +120,7 @@ class Avatar return $fields; } - $filename = self::getFilename($contact['url']); + $filename = self::getFilename($contact['url'], $contact['avatar']); $timestamp = time(); $fields['photo'] = self::storeAvatarCache($image, $filename, Proxy::PIXEL_SMALL, $timestamp); @@ -130,9 +130,9 @@ class Avatar return $fields; } - private static function getFilename(string $url): string + private static function getFilename(string $url, string $host): string { - $guid = Item::guidFromUri($url); + $guid = Item::guidFromUri($url, $host); return substr($guid, 0, 2) . '/' . substr($guid, 3, 2) . '/' . substr($guid, 5, 3) . '/' . substr($guid, 9, 2) .'/' . substr($guid, 11, 2) . '/' . substr($guid, 13, 4). '/' . substr($guid, 18) . '-'; diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 3f830c29a4..720d2638c4 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2773,7 +2773,7 @@ class Contact } $update = false; - $guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url']); + $guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], $ret['baseurl'] ?: $ret['alias']); // make sure to not overwrite existing values with blank entries except some technical fields $keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl']; diff --git a/src/Model/Item.php b/src/Model/Item.php index fad8ffeff4..cdeb6d3d13 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2044,7 +2044,7 @@ class Item // Remove the scheme to make sure that "https" and "http" doesn't make a difference unset($parsed['scheme']); - $hostPart = $host ?? $parsed['host'] ?? ''; + $hostPart = $host ?: $parsed['host'] ?? ''; if (!$hostPart) { Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed, 'callstack' => System::callstack(10)]); } -- 2.39.5