]> git.mxchange.org Git - friendica-addons.git/commitdiff
Use the original application name when mirroring posts.
authorMichael Vogel <icarus@dabo.de>
Fri, 7 Nov 2014 19:06:51 +0000 (20:06 +0100)
committerMichael Vogel <icarus@dabo.de>
Fri, 7 Nov 2014 19:06:51 +0000 (20:06 +0100)
fbpost/fbpost.php
fbsync/fbsync.php
statusnet/statusnet.php
twitter/twitter.php

index 2ac558ea8def501329e32c1b58dafceffebadb4f..5b28c859b07755bb715ffa7f8e6bc3c68a882550 100644 (file)
@@ -428,6 +428,9 @@ function fbpost_post_hook(&$a,&$b) {
        logger('fbpost_post_hook: Facebook post first check successful', LOGGER_DEBUG);
 
        // if post comes from facebook don't send it back
+       if($b['extid'] == NETWORK_FACEBOOK)
+               return;
+
        if(($b['app'] == "Facebook") AND ($b['verb'] != ACTIVITY_LIKE))
                return;
 
@@ -967,8 +970,21 @@ function fbpost_cron($a,$b) {
        set_config('facebook','last_poll', time());
 }
 
+function fbpost_cleanpicture($url) {
+       require_once("include/Photo.php");
+
+       $urldata = parse_url($url);
+       if (isset($urldata["query"])) {
+               parse_str($urldata["query"], $querydata);
+               if (isset($querydata["url"]) AND (get_photo_info($querydata["url"])))
+                       return($querydata["url"]);
+       }
+       return($url);
+}
+
 function fbpost_fetchwall($a, $uid) {
        require_once("include/oembed.php");
+       require_once("include/network.php");
        require_once('mod/item.php');
 
        $access_token = get_pconfig($uid,'facebook','access_token');
@@ -1019,7 +1035,9 @@ function fbpost_fetchwall($a, $uid) {
                $_REQUEST["type"] = "wall";
                $_REQUEST["api_source"] = true;
                $_REQUEST["profile_uid"] = $uid;
-               $_REQUEST["source"] = "Facebook";
+               //$_REQUEST["source"] = "Facebook";
+               $_REQUEST["source"] = $item->application->name;
+               $_REQUEST["extid"] = NETWORK_FACEBOOK;
 
                $_REQUEST["title"] = "";
 
@@ -1029,6 +1047,7 @@ function fbpost_fetchwall($a, $uid) {
                $type = "";
 
                if(isset($item->name) and isset($item->link)) {
+                       $item->link = original_url($item->link);
                        $oembed_data = oembed_fetch_url($item->link);
                        $type = $oembed_data->type;
                        $content = "[bookmark=".$item->link."]".$item->name."[/bookmark]";
@@ -1071,9 +1090,17 @@ function fbpost_fetchwall($a, $uid) {
                                }
                        }
 
-                       if(($picture != "") && isset($item->link))
+                       if(trim($_REQUEST["body"].$content.$quote) == '') {
+                               logger('facebook: empty body 2 '.$item->id.' '.print_r($item, true));
+                               continue;
+                       }
+
+                       $picture = fbpost_cleanpicture($picture);
+
+                       if(($picture != "") && isset($item->link)) {
+                               $item->link = original_url($item->link);
                                $content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]';
-                       else {
+                       else {
                                if ($picture != "")
                                        $content .= "\n".'[img]'.$picture.'[/img]';
                                // if just a link, it may be a wall photo - check
index 51d2747f93d8640570032d8eda81f575c796b412..64f6fe2a34190aa1a5f4de7735a3d305b8ebde0c 100644 (file)
@@ -216,6 +216,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
        $access_token = get_pconfig($uid,'facebook','access_token');
 
        require_once("include/oembed.php");
+       require_once("include/network.php");
 
        // check if it was already imported
        $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
@@ -339,6 +340,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
        $type = "";
 
        if (isset($post->attachment->name) and isset($post->attachment->href)) {
+               $post->attachment->href = original_url($post->attachment->href);
                $oembed_data = oembed_fetch_url($post->attachment->href);
                $type = $oembed_data->type;
                if ($type == "rich")
@@ -391,6 +393,8 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
                                }
                        }
 
+                       $preview = fbpost_cleanpicture($preview);
+
                        if (isset($media->href) AND ($preview != "") AND ($media->href != ""))
                                $content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]';
                        else {
index ce8d170b0506e8bdac48ca48ccdcbda1cf3d3248..7d0f80c3c5e8d98afa2357af7c089c4997c45b76 100644 (file)
@@ -532,6 +532,9 @@ function statusnet_post_hook(&$a,&$b) {
                return;
 
        // if posts comes from statusnet don't send it back
+       if($b['extid'] == NETWORK_STATUSNET)
+               return;
+
        if($b['app'] == "StatusNet")
                return;
 
@@ -829,7 +832,9 @@ function statusnet_fetchtimeline($a, $uid) {
                        $_REQUEST["type"] = "wall";
                        $_REQUEST["api_source"] = true;
                        $_REQUEST["profile_uid"] = $uid;
-                       $_REQUEST["source"] = "StatusNet";
+                       //$_REQUEST["source"] = "StatusNet";
+                       $_REQUEST["source"] = $post->source;
+                       $_REQUEST["extid"] = NETWORK_STATUSNET;
 
                        //$_REQUEST["date"] = $post->created_at;
 
index 2669c46d3e79919a1eb61e141e4e51e7cc47a26b..380121c2e2a40bc0d820e2417021b077a3bfda33 100644 (file)
@@ -438,6 +438,9 @@ function twitter_post_hook(&$a,&$b) {
                return;
 
        // if post comes from twitter don't send it back
+       if($b['extid'] == NETWORK_TWITTER)
+               return;
+
        if($b['app'] == "Twitter")
                return;
 
@@ -743,7 +746,9 @@ function twitter_fetchtimeline($a, $uid) {
                        $_REQUEST["type"] = "wall";
                        $_REQUEST["api_source"] = true;
                        $_REQUEST["profile_uid"] = $uid;
-                       $_REQUEST["source"] = "Twitter";
+                       //$_REQUEST["source"] = "Twitter";
+                       $_REQUEST["source"] = $post->source;
+                       $_REQUEST["extid"] = NETWORK_TWITTER;
 
                        //$_REQUEST["date"] = $post->created_at;