]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Merge branch 'develop' into new_image_presentation
[friendica.git] / src / Protocol / DFRN.php
index 7540d99d9f8bb34df3127f6f8fe8bfb6070f1c35..92f3e8154548aa891a8f9d3797ce9cece8a11f2c 100644 (file)
@@ -25,6 +25,7 @@ use DOMDocument;
 use DOMElement;
 use DOMNode;
 use DOMXPath;
+use Friendica\App;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
@@ -33,7 +34,6 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Conversation;
 use Friendica\Model\Event;
-use Friendica\Model\FContact;
 use Friendica\Model\GServer;
 use Friendica\Model\Item;
 use Friendica\Model\ItemURI;
@@ -44,6 +44,7 @@ use Friendica\Model\Post;
 use Friendica\Model\Profile;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
+use Friendica\Network\HTTPException;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
@@ -369,8 +370,8 @@ class DFRN
                XML::addElement($doc, $root, 'id', DI::baseUrl() . '/profile/' . $owner['nick']);
                XML::addElement($doc, $root, 'title', $owner['name']);
 
-               $attributes = ['uri' => 'https://friendi.ca', 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION];
-               XML::addElement($doc, $root, 'generator', FRIENDICA_PLATFORM, $attributes);
+               $attributes = ['uri' => 'https://friendi.ca', 'version' => App::VERSION . '-' . DB_UPDATE_VERSION];
+               XML::addElement($doc, $root, 'generator', App::PLATFORM, $attributes);
 
                $attributes = ['rel' => 'license', 'href' => 'http://creativecommons.org/licenses/by/3.0/'];
                XML::addElement($doc, $root, 'link', '', $attributes);
@@ -537,7 +538,7 @@ class DFRN
 
                        XML::addElement($doc, $author, 'poco:utcOffset', DateTimeFormat::timezoneNow($profile['timezone'], 'P'));
 
-                       if (trim($profile['homepage']) != '') {
+                       if (trim($profile['homepage'])) {
                                $urls = $doc->createElement('poco:urls');
                                XML::addElement($doc, $urls, 'poco:type', 'homepage');
                                XML::addElement($doc, $urls, 'poco:value', $profile['homepage']);
@@ -545,7 +546,7 @@ class DFRN
                                $author->appendChild($urls);
                        }
 
-                       if (trim($profile['pub_keywords']) != '') {
+                       if (trim($profile['pub_keywords'] ?? '')) {
                                $keywords = explode(',', $profile['pub_keywords']);
 
                                foreach ($keywords as $keyword) {
@@ -553,7 +554,7 @@ class DFRN
                                }
                        }
 
-                       if (trim($profile['xmpp']) != '') {
+                       if (trim($profile['xmpp'])) {
                                $ims = $doc->createElement('poco:ims');
                                XML::addElement($doc, $ims, 'poco:type', 'xmpp');
                                XML::addElement($doc, $ims, 'poco:value', $profile['xmpp']);
@@ -561,7 +562,7 @@ class DFRN
                                $author->appendChild($ims);
                        }
 
-                       if (trim($profile['locality'] . $profile['region'] . $profile['country-name']) != '') {
+                       if (trim($profile['locality'] . $profile['region'] . $profile['country-name'])) {
                                $element = $doc->createElement('poco:address');
 
                                XML::addElement($doc, $element, 'poco:formatted', Profile::formatLocation($profile));
@@ -773,7 +774,7 @@ class DFRN
                        $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
                }
 
-               $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body'] ?? '');
+               $body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
 
                if ($item['private'] == Item::PRIVATE) {
                        $body = Item::fixPrivatePhotos($body, $owner['uid'], $item, $cid);
@@ -980,12 +981,12 @@ class DFRN
                                }
                        }
 
-                       $fcontact = FContact::getByURL($contact['addr']);
-                       if (empty($fcontact)) {
+                       try {
+                               $pubkey = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']))->pubKey;
+                       } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
                                Logger::notice('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']);
                                return -22;
                        }
-                       $pubkey = $fcontact['pubkey'] ?? '';
                } else {
                        $pubkey = '';
                }
@@ -1837,7 +1838,11 @@ class DFRN
 
                $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
 
-               $item['body'] = Item::improveSharedDataInBody($item);
+               $quote_uri_id = Item::getQuoteUriId($item['body'], $item['uid']);
+               if (!empty($quote_uri_id)) {
+                       $item['quote-uri-id'] = $quote_uri_id;
+                       $item['body']         = BBCode::removeSharedData($item['body']);
+               }
 
                Tag::storeFromBody($item['uri-id'], $item['body']);