From eec6cdf01b1c14cf0c99fe91928b99ad5ed7588e Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 5 Aug 2021 08:51:39 +0000 Subject: [PATCH] Avoid a database query when possible --- src/Protocol/Diaspora.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 2c3e9add63..485e5a7846 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4051,13 +4051,18 @@ class Diaspora */ public static function createCommentSignature(array $item) { - $contact = Contact::getById($item['author-id'], ['url']); - if (empty($contact['url'])) { - Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]); - return false; + if (!empty($item['author-link'])) { + $url = $item['author-link']; + } else { + $contact = Contact::getById($item['author-id'], ['url']); + if (empty($contact['url'])) { + Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]); + return false; + } + $url = $contact['url']; } - $uid = User::getIdForURL($contact['url']); + $uid = User::getIdForURL($url); if (empty($uid)) { Logger::info('No owner post, so not storing signature', ['url' => $contact['url']]); return false;