}
// 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;
'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);
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;
}
*
* @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;
}
}
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;
}
*
* @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)) {
}
// 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;
}