]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #10787 from fabrixxm/issue/10767
[friendica.git] / src / Model / Item.php
index 441808ea91116fd91be00de98554c39d15d51fa0..8327252abc7acc2f69bb062cb732e06884edd2e9 100644 (file)
@@ -659,6 +659,12 @@ class Item
                $params = ['order' => ['id' => false]];
                $parent = Post::selectFirst($fields, $condition, $params);
 
+               if (!DBA::isResult($parent) && $item['origin']) {
+                       $stored = Item::storeForUserByUriId($item['thr-parent-id'], $item['uid']);
+                       Logger::info('Stored thread parent item for user', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid'], 'stored' => $stored]);
+                       $parent = Post::selectFirst($fields, $condition, $params);
+               }
+
                if (!DBA::isResult($parent)) {
                        Logger::notice('item parent was not found - ignoring item', ['thr-parent-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
                        return [];
@@ -673,6 +679,13 @@ class Item
                        'uid' => $parent['uid']];
                $params = ['order' => ['id' => false]];
                $toplevel_parent = Post::selectFirst($fields, $condition, $params);
+
+               if (!DBA::isResult($toplevel_parent) && $item['origin']) {
+                       $stored = Item::storeForUserByUriId($item['parent-uri-id'], $item['uid']);
+                       Logger::info('Stored parent item for user', ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'stored' => $stored]);
+                       $toplevel_parent = Post::selectFirst($fields, $condition, $params);
+               }
+
                if (!DBA::isResult($toplevel_parent)) {
                        Logger::notice('item top level parent was not found - ignoring item', ['parent-uri-id' => $parent['parent-uri-id'], 'uid' => $parent['uid']]);
                        return [];
@@ -1039,7 +1052,7 @@ class Item
                                }
 
                                $event_id = Event::store($ev);
-                               $item = Event::getItemArrayForId($event_id, $item);
+                               $item = Event::getItemArrayForImportedId($event_id, $item);
 
                                Logger::info('Event was stored', ['id' => $event_id]);
                        }
@@ -1160,8 +1173,6 @@ class Item
 
                Post\UserNotification::setNotification($posted_item['uri-id'], $posted_item['uid']);
 
-               check_user_notification($posted_item['uri-id'], $posted_item['uid']);
-
                // Distribute items to users who subscribed to their tags
                self::distributeByTags($posted_item);
 
@@ -2757,6 +2768,8 @@ class Item
                                $filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
                        }
 
+                       $item['attachments'] = $attachments;
+
                        $hook_data = [
                                'item' => $item,
                                'filter_reasons' => $filter_reasons