From 476cb92a3b29cc448c67e912ec55af37baf879b1 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 2 Apr 2018 07:12:43 +0000 Subject: [PATCH] Only add picture link under conditions --- twitter/twitter.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index 72a9682b..5036f515 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -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 = ""; } } -- 2.39.5