]> git.mxchange.org Git - friendica-addons.git/commitdiff
facebook, statusnet and twitter: Now shared messages are clearly marked with the...
authorMichael Vogel <icarus@dabo.de>
Sun, 28 Jul 2013 18:40:37 +0000 (20:40 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 28 Jul 2013 18:40:37 +0000 (20:40 +0200)
twitter: When a post with a picture failes than the post is repeated without a picture
fromgplus: Under certain circumenstances "fromgplus" generates an empty post that is blocking the cron hook - so now messages are mirrored anymore.

fbpost/fbpost.php
fromgplus/fromgplus.php
statusnet/statusnet.php
twitter/twitter.php

index be9fc2902fea197733285d665804c20d187e0511..0fc6dd6544131a708285a01e8ac4512681009e35 100644 (file)
@@ -570,25 +570,25 @@ function fbpost_post_hook(&$a,&$b) {
                                $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body);
 
                                // share element
-                               $body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","fbpost_ShareAttributes", $body);
+                               //$body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","fbpost_ShareAttributes", $body);
 
-                               $bodyparts = explode("\t", $body);
+                               //$bodyparts = explode("\t", $body);
                                // Doesn't help with multiple repeats - the problem has to be solved later
-                               if (sizeof($bodyparts) == 3) {
-                                       $html = bbcode($bodyparts[2], false, false);
-                                       $test = trim(html2plain($html, 0, true));
-
-                                       if (trim($bodyparts[0]) == "")
-                                               $body = trim($bodyparts[2]);
-                                       else if (trim($test) == "")
-                                               $body = trim($bodyparts[0]);
-                                       else
-                                               $body = trim($bodyparts[0])."\n\n".trim($bodyparts[1])."[quote]".trim($bodyparts[2])."[/quote]";
-                               } else
+                               //if (sizeof($bodyparts) == 3) {
+                               //      $html = bbcode($bodyparts[2], false, false);
+                               //      $test = trim(html2plain($html, 0, true));
+
+                               //      if (trim($bodyparts[0]) == "")
+                               //              $body = trim($bodyparts[2]);
+                               //      else if (trim($test) == "")
+                               //              $body = trim($bodyparts[0]);
+                               //      else
+                               //              $body = trim($bodyparts[0])."\n\n".trim($bodyparts[1])."[quote]".trim($bodyparts[2])."[/quote]";
+                               //} else
                                        $body = str_replace("\t", "", $body);
 
                                // At first convert the text to html
-                               $html = bbcode($body, false, false);
+                               $html = bbcode($body, false, false, 2);
 
                                // Then convert it to plain text
                                $msg = trim($b['title']." \n\n".html2plain($html, 0, true));
index fdd0b579a4f9a0a17fb440a0483dbb860d8326c9..94b12af345647ce815c0ab1d8026bd0dcd53ed3c 100644 (file)
@@ -124,11 +124,16 @@ function fromgplus_post($a, $uid, $source, $body, $location) {
        $_REQUEST['body'] = $body;
        $_REQUEST['location'] = $location;
 
-        logger('fromgplus: posting for user '.$uid);
+       if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
+               logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
+               return;
+       }
 
        require_once('mod/item.php');
        //print_r($_REQUEST);
+        logger('fromgplus: posting for user '.$uid." ".print_r($_REQUEST, true));
        item_post($a);
+        logger('fromgplus: done for user '.$uid);
 }
 
 function fromgplus_html2bbcode($html) {
index bd2312f7ae97c9337de495ea1d222fa7497d2a6d..d168955cd4deec2e3d95350e8da7b12ad1d48f35 100755 (executable)
@@ -491,10 +491,10 @@ function statusnet_shortenmsg($b, $max_char) {
        $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body);
 
        // remove the share element
-       $body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body);
+       //$body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body);
 
        // At first convert the text to html
-       $html = bbcode($body, false, false);
+       $html = bbcode($body, false, false, 2);
 
        // Then convert it to plain text
        //$msg = trim($b['title']." \n\n".html2plain($html, 0, true));
index 3de55353f6addd243e002b42c34c65ce06f19bf5..bd9eb18c32acac196bbb1deb94fc6e6c791744e7 100755 (executable)
@@ -357,10 +357,10 @@ function twitter_shortenmsg($b) {
        $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body);
 
        // remove the share element
-       $body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body);
+       //$body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body);
 
        // At first convert the text to html
-       $html = bbcode($body, false, false);
+       $html = bbcode($body, false, false, 2);
 
        // Then convert it to plain text
        //$msg = trim($b['title']." \n\n".html2plain($html, 0, true));
@@ -628,13 +628,7 @@ function twitter_post_hook(&$a,&$b) {
                         $image = $msgarr["image"];
 
                // and now tweet it :-)
-               if(strlen($msg) and ($image == "")) {
-                       $result = $tweet->post('statuses/update', array('status' => $msg));
-                       logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
-                       if ($result->error) {
-                               logger('Send to Twitter failed: "' . $result->error . '"');
-                       }
-               } else if(strlen($msg) and ($image != "")) {
+               if(strlen($msg) and ($image != "")) {
                        $img_str = fetch_url($image);
 
                        $tempfile = tempnam(get_config("system","temppath"), "cache");
@@ -649,8 +643,17 @@ function twitter_post_hook(&$a,&$b) {
                        logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG);
                        if ($result->error) {
                                logger('Send to Twitter failed: "' . $result->error . '"');
+                               // Workaround: Remove the picture link so that the post can be reposted without it
+                               $image = "";
                        }
                }
+
+               if(strlen($msg) and ($image == "")) {
+                       $result = $tweet->post('statuses/update', array('status' => $msg));
+                       logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
+                       if ($result->error)
+                               logger('Send to Twitter failed: "' . $result->error . '"');
+               }
        }
 }