}
// 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);
return false;
}
+ if (!Item::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $uid])) {
+ $parent_item = self::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $item['parent-uri-id'], 'uid' => 0]);
+ if (!empty($parent_item) && ($parent_item['private'] != self::PRIVATE)) {
+ $stored = self::storeForUser($parent_item, $uid);
+ Logger::info('Public item stored for user', ['uri-id' => $parent_item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
+ }
+ }
+
// Retrieves the local post owner
$owner_self_contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($owner_self_contact)) {
*
* @return integer item id
*/
- public static function fetchByLink($uri, $uid = 0)
+ public static function fetchByLink(string $uri, int $uid = 0)
{
$item_id = self::searchByLink($uri, $uid);
if (!empty($item_id)) {
*
* @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;
}