X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=586b6e9ec282e8b425adfbf42adff5a71d995bcc;hb=7155f825daf90f4113ba3e8755eb51898b8e5736;hp=79151c140fecc75799417e0f7d711e5ea707bc58;hpb=454fbc8ad7c2f849d0540a2ab2fbab2af2270bd4;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 79151c140f..586b6e9ec2 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1,6 +1,6 @@ The public key of the author * @throws \Exception */ - private static function message($guid, $server, $level = 0) + public static function message($guid, $server, $level = 0) { if ($level > 5) { return false; @@ -1498,6 +1498,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + $message_id = self::messageExists($importer["uid"], $guid); if ($message_id) { return true; @@ -1531,11 +1535,11 @@ class Diaspora // Will be overwritten for sharing accounts in Item::insert if ($fetched) { - $datarray["post-type"] = Item::PT_FETCHED; + $datarray["post-reason"] = Item::PR_FETCHED; } elseif ($datarray["uid"] == 0) { - $datarray["post-type"] = Item::PT_GLOBAL; + $datarray["post-reason"] = Item::PR_GLOBAL; } else { - $datarray["post-type"] = Item::PT_COMMENT; + $datarray["post-reason"] = Item::PR_COMMENT; } $datarray["guid"] = $guid; @@ -1548,6 +1552,7 @@ class Diaspora $datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri']; $datarray["object-type"] = Activity\ObjectType::COMMENT; + $datarray["post-type"] = Item::PT_NOTE; $datarray["protocol"] = Conversation::PARCEL_DIASPORA; $datarray["source"] = $xml; @@ -1682,6 +1687,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + $conversation = DBA::selectFirst('conv', [], ['uid' => $importer["uid"], 'guid' => $guid]); if (!DBA::isResult($conversation)) { $r = q( @@ -1741,6 +1750,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + $message_id = self::messageExists($importer["uid"], $guid); if ($message_id) { return true; @@ -1851,6 +1864,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + $conversation = null; $condition = ['uid' => $importer["uid"], 'guid' => $conversation_guid]; @@ -1911,6 +1928,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + if (self::messageExists($importer["uid"], $guid)) { return true; } @@ -2281,9 +2302,6 @@ class Diaspora $item["body"] = self::replacePeopleGuid($item["body"], $item["author-link"]); - // Add OEmbed and other information to the body - $item["body"] = PageInfo::searchAndAppendToBody($item["body"], false, true); - return $item; } else { return $item; @@ -2407,6 +2425,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + $message_id = self::messageExists($importer["uid"], $guid); if ($message_id) { return true; @@ -2463,7 +2485,6 @@ class Diaspora Tag::storeFromBody($datarray['uri-id'], $datarray["body"]); - Post\Media::copy($original_item['uri-id'], $datarray['uri-id']); $datarray["app"] = $original_item["app"]; $datarray["plink"] = self::plink($author, $guid); @@ -2679,6 +2700,10 @@ class Diaspora return false; } + if (!empty($contact['gsid'])) { + GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA); + } + $message_id = self::messageExists($importer["uid"], $guid); if ($message_id) { return true; @@ -2703,18 +2728,13 @@ class Diaspora if ($data->photo) { foreach ($data->photo as $photo) { self::storePhotoAsMedia($datarray['uri-id'], $photo); - $body = "[img]".XML::unescape($photo->remote_photo_path). - XML::unescape($photo->remote_photo_name)."[/img]\n".$body; } $datarray["object-type"] = Activity\ObjectType::IMAGE; + $datarray["post-type"] = Item::PT_IMAGE; } else { $datarray["object-type"] = Activity\ObjectType::NOTE; - - // Add OEmbed and other information to the body - if (!self::isHubzilla($contact["url"])) { - $body = PageInfo::searchAndAppendToBody($body, false, true); - } + $datarray["post-type"] = Item::PT_NOTE; } /// @todo enable support for polls @@ -2744,9 +2764,9 @@ class Diaspora $datarray["direction"] = $fetched ? Conversation::PULL : Conversation::PUSH; if ($fetched) { - $datarray["post-type"] = Item::PT_FETCHED; + $datarray["post-reason"] = Item::PR_FETCHED; } elseif ($datarray["uid"] == 0) { - $datarray["post-type"] = Item::PT_GLOBAL; + $datarray["post-reason"] = Item::PR_GLOBAL; } $datarray["body"] = self::replacePeopleGuid($body, $contact["url"]); @@ -2850,9 +2870,9 @@ class Diaspora return false; } - $aes_key = openssl_random_pseudo_bytes(32); + $aes_key = random_bytes(32); $b_aes_key = base64_encode($aes_key); - $iv = openssl_random_pseudo_bytes(16); + $iv = random_bytes(16); $b_iv = base64_encode($iv); $ciphertext = self::aesEncrypt($aes_key, $iv, $msg); @@ -3099,18 +3119,7 @@ class Diaspora return; } - // Fetch some user id to have a valid handle to transmit the participation. - // In fact it doesn't matter which user sends this - but it is needed by the protocol. - // If the item belongs to a user, we take this user id. - if ($item['uid'] == 0) { - $condition = ['verified' => true, 'blocked' => false, - 'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON]; - $first_user = DBA::selectFirst('user', ['uid'], $condition, ['order' => ['uid']]); - $owner = User::getOwnerDataById($first_user['uid']); - } else { - $owner = User::getOwnerDataById($item['uid']); - } - + $owner = User::getOwnerDataById($item['uid']); $author = self::myHandle($owner); $message = ["author" => $author, @@ -3397,7 +3406,7 @@ class Diaspora $type = "reshare"; } else { $title = $item["title"]; - $body = $item["body"]; + $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']); // Fetch the title from an attached link - if there is one if (empty($item["title"]) && DI::pConfig()->get($owner['uid'], 'system', 'attach_link_title')) { @@ -3611,7 +3620,7 @@ class Diaspora $thread_parent_item = Post::selectFirst(['guid', 'author-id', 'author-link', 'gravity'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]); } - $body = $item["body"]; + $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']); // The replied to autor mention is prepended for clarity if: // - Item replied isn't yours @@ -4040,13 +4049,11 @@ class Diaspora return false; } - $parent = Post::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]); - if (!DBA::isResult($parent)) { - return; + // This is only needed for the automated tests + if (empty($owner['uprvkey'])) { + return false; } - $item['parent-uri'] = $parent['parent-uri']; - $message = self::constructComment($item, $owner); if ($message === false) { return false;