]> 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 f626582babf17321fc4b1ca7338b59d76bfe411e..92f3e8154548aa891a8f9d3797ce9cece8a11f2c 100644 (file)
@@ -34,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;
@@ -45,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;
@@ -538,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']);
@@ -546,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) {
@@ -554,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']);
@@ -562,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));
@@ -774,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);
@@ -981,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 = '';
                }
@@ -1838,7 +1838,11 @@ class DFRN
 
                $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
 
-               $item['body'] = DI::contentItem()->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']);