X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=b6f8ffa3d1665e5950aa3b69e9dbb05a868fea50;hb=24a82110fd45a8422efee0677b7acc214aa66e9a;hp=98e4cdf307abb9f48cc8dc31ba20afda6ffbd92a;hpb=ca9f8e7420d925fb316f8841f338a4583d94fe51;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index 98e4cdf307..b6f8ffa3d1 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1554,9 +1554,7 @@ class Item } // Update the contact relations - if ($item['author-id'] != $parent['author-id']) { - DBA::update('contact-relation', ['last-interaction' => $item['created']], ['cid' => $parent['author-id'], 'relation-cid' => $item['author-id']], true); - } + ContactRelation::store($parent['author-id'], $item['author-id'], $item['created']); } return $item; @@ -1703,6 +1701,10 @@ class Item 'photo' => $item['owner-avatar'], 'network' => $item['network']]; $item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, null, $default); + // Ensure that there is an avatar cache + Contact::checkAvatarCache($item['author-id']); + Contact::checkAvatarCache($item['owner-id']); + // The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes $item["contact-id"] = self::contactId($item); @@ -2173,7 +2175,12 @@ class Item public static function storeForUserByUriId(int $uri_id, int $uid) { $item = self::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $uri_id, 'uid' => 0]); - if (empty($item) || ($item['private'] != self::PRIVATE)) { + if (!DBA::isResult($item)) { + return 0; + } + + if (($item['private'] == self::PRIVATE) || !in_array($item['network'], Protocol::FEDERATED)) { + Logger::notice('Item is private or not from a federated network. It will not be stored for the user.', ['uri-id' => $uri_id, 'uid' => $uid, 'private' => $item['private'], 'network' => $item['network']]); return 0; } @@ -3696,10 +3703,12 @@ class Item * * @return integer item id */ - public static function fetchByLink($uri, $uid = 0) + public static function fetchByLink(string $uri, int $uid = 0) { + Logger::info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]); $item_id = self::searchByLink($uri, $uid); if (!empty($item_id)) { + Logger::info('Link found', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]); return $item_id; } @@ -3710,9 +3719,11 @@ class Item } if (!empty($item_id)) { + Logger::info('Link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]); return $item_id; } + Logger::info('Link not found', ['uid' => $uid, 'uri' => $uri]); return 0; } @@ -3749,7 +3760,7 @@ class Item * * @return array item array with data from the original item */ - public static function addShareDataFromOriginal($item) + public static function addShareDataFromOriginal(array $item) { $shared = self::getShareArray($item); if (empty($shared)) { @@ -3771,9 +3782,9 @@ class Item } // Otherwhise try to find (and possibly fetch) the item via the link. This should work for Diaspora and ActivityPub posts - $id = self::fetchByLink($shared['link'], $uid); + $id = self::fetchByLink($shared['link'] ?? '', $uid); if (empty($id)) { - Logger::info('Original item not found', ['url' => $shared['link'], 'callstack' => System::callstack()]); + Logger::info('Original item not found', ['url' => $shared['link'] ?? '', 'callstack' => System::callstack()]); return $item; }