]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
removed unneeded notification check
[friendica.git] / src / Model / Item.php
index 1c61dfcdd34635cd9b8539d15716d47d40b9c98c..778b872bbb751452c2894c6ba2d2c2c94aebeba8 100644 (file)
@@ -1994,25 +1994,31 @@ class Item
        /**
         * Convert items to forum posts
         *
+        * (public) forum posts in the new format consist of the regular post by the author
+        * followed by an announce message sent from the forum account.
+        * This means we have to look out for an announce message send by a forum account.
+        *
         * @param array $item
         * @return void
         */
        private static function transformToForumPost(array $item)
        {
                if ($item["verb"] != Activity::ANNOUNCE) {
+                       // No announce message, so don't do anything
                        return;
                }
 
                $pcontact = Contact::selectFirst(['nurl'], ['id' => $item['author-id'], 'contact-type' => Contact::TYPE_COMMUNITY]);
                if (empty($pcontact['nurl'])) {
+                       // The announce message wasn't created by a forum account, so we don't need to continue
                        return;
                }
 
                $contact = Contact::selectFirst(['id'], ['nurl' => $pcontact['nurl'], 'uid' => $item['uid']]);
                if (!empty($contact['id'])) {
-                       Item::update(['owner-id' => $item['author-id'], 'contact-id' => $contact['id']],
-                               ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
-                       LOgger::info('Convert message into a forum message', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $contact['id']]);
+                       $condition = ['uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']];
+                       Item::update(['owner-id' => $item['author-id'], 'contact-id' => $contact['id']], $condition);
+                       Logger::info('Convert message into a forum message', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid'], 'owner-id' => $item['author-id'], 'contact-id' => $contact['id']]);
                }
        }