Avoid a database query when possible

This commit is contained in:
Michael 2021-08-05 08:51:39 +00:00
parent 835152d418
commit eec6cdf01b

View File

@ -4051,13 +4051,18 @@ class Diaspora
*/ */
public static function createCommentSignature(array $item) public static function createCommentSignature(array $item)
{ {
if (!empty($item['author-link'])) {
$url = $item['author-link'];
} else {
$contact = Contact::getById($item['author-id'], ['url']); $contact = Contact::getById($item['author-id'], ['url']);
if (empty($contact['url'])) { if (empty($contact['url'])) {
Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]); Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
return false; return false;
} }
$url = $contact['url'];
}
$uid = User::getIdForURL($contact['url']); $uid = User::getIdForURL($url);
if (empty($uid)) { if (empty($uid)) {
Logger::info('No owner post, so not storing signature', ['url' => $contact['url']]); Logger::info('No owner post, so not storing signature', ['url' => $contact['url']]);
return false; return false;