]> git.mxchange.org Git - friendica-addons.git/commitdiff
Only add picture link under conditions
authorMichael <heluecht@pirati.ca>
Mon, 2 Apr 2018 07:12:43 +0000 (07:12 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 2 Apr 2018 07:12:43 +0000 (07:12 +0000)
twitter/twitter.php

index 72a9682be624504bc3d60c860045db9970140c11..5036f515eb517d8511d31e7bc417d3d6f836a5fd 100644 (file)
@@ -528,8 +528,8 @@ function twitter_post_hook(App $a, &$b)
 
                $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
 
-               // Set the timeout for upload to 15 seconds
-               $connection->setTimeouts(10, 15);
+               // Set the timeout for upload to 30 seconds
+               $connection->setTimeouts(10, 30);
 
                $max_char = 280;
                $msgarr = BBCode::toPlaintext($b, $max_char, true, 8);
@@ -543,6 +543,9 @@ function twitter_post_hook(App $a, &$b)
 
                if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
                        $msg .= "\n" . $msgarr["url"];
+                       $url_added = true;
+               } else {
+                       $url_added = false;
                }
 
                if (isset($msgarr["image"]) && ($msgarr["type"] != "video")) {
@@ -572,7 +575,11 @@ function twitter_post_hook(App $a, &$b)
                                logger('Exception when trying to send to Twitter: ' . $e->getMessage());
 
                                // Workaround: Remove the picture link so that the post can be reposted without it
-                               $msg .= " " . $image;
+                               // When there is another url already added, a second url would be superfluous.
+                               if (!$url_added) {
+                                       $msg .= "\n" . $image;
+                               }
+
                                $image = "";
                        }
                }