+ if (($itemuid != local_user()) AND local_user()) {
+ // Do we know this contact but we haven't got this item?
+ // Copy the wohle thread to our local storage so that we can interact.
+ // We really should change this need for the future since it scales very bad.
+ $contactid = get_contact($r[0]['owner-link'], local_user());
+ if ($contactid) {
+ $items = q("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id`", intval($r[0]["id"]));
+ foreach ($items AS $item) {
+ $itemcontactid = get_contact($item['owner-link'], local_user());
+ if (!$itemcontactid)
+ $itemcontactid = $contactid;
+
+ unset($item['id']);
+ $item['uid'] = local_user();
+ $item['origin'] = 0;
+ $item['contact-id'] = $itemcontactid;
+ $local_copy = item_store($item, false, false, true);
+ logger("Stored local copy for post ".$item['guid']." under id ".$local_copy, LOGGER_DEBUG);
+ }
+ }
+ }
+