]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #5912 from MrPetovan/bug/fix-code-tag-nonsense
[friendica.git] / src / Model / Item.php
index e33cf020d8e02d3ec88fa55db6c6359692fd9590..ed80f4e9e802acf735b6adf4e47225afd6a33f86 100644 (file)
@@ -1081,9 +1081,8 @@ class Item extends BaseObject
 
                DBA::delete('item-delivery-data', ['iid' => $item['id']]);
 
-               //if (!empty($item['iaid']) && !self::exists(['iaid' => $item['iaid'], 'deleted' => false])) {
-               //      DBA::delete('item-activity', ['id' => $item['iaid']], ['cascade' => false]);
-               //}
+               // We don't delete the item-activity here, since we need some of the data for ActivityPub
+
                if (!empty($item['icid']) && !self::exists(['icid' => $item['icid'], 'deleted' => false])) {
                        DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
                }
@@ -1167,7 +1166,7 @@ class Item extends BaseObject
                if ($notify) {
                        // We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri.
                        // We add the hash of our own host because our host is the original creator of the post.
-                       $prefix_host = get_app()->get_hostname();
+                       $prefix_host = get_app()->getHostName();
                } else {
                        $prefix_host = '';
 
@@ -1205,7 +1204,7 @@ class Item extends BaseObject
                } elseif (!empty($item['uri'])) {
                        $guid = self::guidFromUri($item['uri'], $prefix_host);
                } else {
-                       $guid = System::createGUID(32, hash('crc32', $prefix_host));
+                       $guid = System::createUUID(hash('crc32', $prefix_host));
                }
 
                return $guid;
@@ -1290,17 +1289,16 @@ class Item extends BaseObject
                 */
 
                $dsprsig = null;
-               if (x($item, 'dsprsig')) {
+               if (isset($item['dsprsig'])) {
                        $encoded_signature = $item['dsprsig'];
                        $dsprsig = json_decode(base64_decode($item['dsprsig']));
                        unset($item['dsprsig']);
                }
 
-               if (!empty($item['diaspora_signed_text'])) {
+               $diaspora_signed_text = '';
+               if (isset($item['diaspora_signed_text'])) {
                        $diaspora_signed_text = $item['diaspora_signed_text'];
                        unset($item['diaspora_signed_text']);
-               } else {
-                       $diaspora_signed_text = '';
                }
 
                // Converting the plink
@@ -1489,6 +1487,7 @@ class Item extends BaseObject
                $deny_gid  = '';
 
                if ($item['parent-uri'] === $item['uri']) {
+                       $diaspora_signed_text = '';
                        $parent_id = 0;
                        $parent_deleted = 0;
                        $allow_cid = $item['allow_cid'];
@@ -1535,6 +1534,10 @@ class Item extends BaseObject
                                $item['wall']    = $parent['wall'];
                                $notify_type    = 'comment-new';
 
+                               if (!$parent['origin']) {
+                                       $diaspora_signed_text = '';
+                               }
+
                                /*
                                 * If the parent is private, force privacy for the entire conversation
                                 * This differs from the above settings as it subtly allows comments from
@@ -1575,6 +1578,7 @@ class Item extends BaseObject
                                        $parent_id = 0;
                                        $item['parent-uri'] = $item['uri'];
                                        $item['gravity'] = GRAVITY_PARENT;
+                                       $diaspora_signed_text = '';
                                } else {
                                        logger('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item');
                                        return 0;
@@ -2359,10 +2363,10 @@ class Item extends BaseObject
        public static function newURI($uid, $guid = "")
        {
                if ($guid == "") {
-                       $guid = System::createGUID(32);
+                       $guid = System::createUUID();
                }
 
-               return self::getApp()->get_baseurl() . '/object/' . $guid;
+               return self::getApp()->getBaseURL() . '/objects/' . $guid;
        }
 
        /**
@@ -2645,7 +2649,7 @@ class Item extends BaseObject
                }
 
                // Prevent to forward already forwarded posts
-               if ($datarray["app"] == $a->get_hostname()) {
+               if ($datarray["app"] == $a->getHostName()) {
                        logger('Already forwarded (second test)', LOGGER_DEBUG);
                        return false;
                }
@@ -2686,7 +2690,7 @@ class Item extends BaseObject
                        }
 
                        if ($contact['network'] != Protocol::FEED) {
-                               $datarray["guid"] = System::createGUID(32);
+                               $datarray["guid"] = System::createUUID();
                                unset($datarray["plink"]);
                                $datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
                                $datarray["parent-uri"] = $datarray["uri"];
@@ -3112,10 +3116,10 @@ class Item extends BaseObject
                        return true;
                }
 
-               $objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
+               $objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE;
 
                $new_item = [
-                       'guid'          => System::createGUID(32),
+                       'guid'          => System::createUUID(),
                        'uri'           => self::newURI($item['uid']),
                        'uid'           => $item['uid'],
                        'contact-id'    => $item_contact_id,
@@ -3126,7 +3130,7 @@ class Item extends BaseObject
                        'parent'        => $item['id'],
                        'parent-uri'    => $item['uri'],
                        'thr-parent'    => $item['uri'],
-                       'owner-id'      => $item['owner-id'],
+                       'owner-id'      => $author_id,
                        'author-id'     => $author_id,
                        'body'          => $activity,
                        'verb'          => $activity,