]> git.mxchange.org Git - friendica-addons.git/commitdiff
Tumblr: Handle quote shares
authorMichael <heluecht@pirati.ca>
Sun, 10 Mar 2024 06:17:18 +0000 (06:17 +0000)
committerTobias Diekershoff <tobias@noreply.git.friendi.ca>
Sun, 10 Mar 2024 14:01:33 +0000 (15:01 +0100)
tumblr/tumblr.php

index 12e9e5e033387bf971bbacb8ae021d3e8050c872..78e415ee0cacc624747f853034a88beb5ea9a877 100644 (file)
@@ -677,11 +677,20 @@ function tumblr_send_npf(array $post): bool
                return true;
        }
 
-       $post['body'] = Post\Media::addAttachmentsToBody($post['uri-id'], $post['body']);
+       $post['body'] = Post\Media::addAttachmentsToBody($post['uri-id'], $post['body'], [Post\Media::IMAGE, Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::ACTIVITY]);
        if (!empty($post['title'])) {
                $post['body'] = '[h1]' . $post['title'] . "[/h1]\n" . $post['body'];
        }
 
+       if (!empty($post['quote-uri-id'])) {
+               $quote = Post::selectFirstPost(['uri', 'plink'], ['uri-id' => $post['quote-uri-id']]);
+               if (!empty($quote)) {
+                       if ((strpos($post['body'], $quote['plink'] ?: $quote['uri']) === false) && (strpos($post['body'], $quote['uri']) === false)) {
+                               $post['body'] .= "\n[url]" . ($quote['plink'] ?: $quote['uri']) . "[/url]\n";
+                       }
+               }
+       }
+
        $params = [
                'content'                => NPF::fromBBCode($post['body'], $post['uri-id']),
                'state'                  => 'published',