]> git.mxchange.org Git - friendica-addons.git/commitdiff
Improved loop detection for Google+, Pump.io, Twitter and GNU Social
authorMichael Vogel <icarus@dabo.de>
Sun, 22 Mar 2015 07:55:45 +0000 (08:55 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 22 Mar 2015 07:55:45 +0000 (08:55 +0100)
fromgplus/fromgplus.php
gpluspost/gpluspost.php
pumpio/pumpio.php
statusnet/statusnet.php
twitter/twitter.php

index 17300ae8ee0a74f12d083a5a7c2f4fd94227defd..e0725a46df22a295d529653db453358be85be6c3 100644 (file)
@@ -416,6 +416,7 @@ function fromgplus_fetch($a, $uid) {
        $reversed = array_reverse($activities->items);
 
        foreach($reversed as $item) {
+
                if (strtotime($item->published) <= $initiallastdate)
                        continue;
 
@@ -431,14 +432,11 @@ function fromgplus_fetch($a, $uid) {
                if ($first_time)
                        continue;
 
-               if ($item->access->description == "Public")
-
-                       // Loop prevention - ignore postings from HootSuite
-                       if ($item->provider->title == "HootSuite")
-                               continue;
+               if ($item->access->description == "Public") {
 
                        // Loop prevention through the special blank from the googleplus connector
-                       if (strstr($item->object->content, $blank))
+                       //if (strstr($item->object->content, $blank))
+                       if (strrpos($item->object->content, $blank) >= strlen($item->object->content) - 5)
                                continue;
 
                        switch($item->object->objectType) {
@@ -454,8 +452,8 @@ function fromgplus_fetch($a, $uid) {
                                        else
                                                $location = "";
 
-                                       fromgplus_post($a, $uid, "Google+", $post, $location);
-                                       //fromgplus_post($a, $uid, $item->provider->title, $post, $location);
+                                       //fromgplus_post($a, $uid, "Google+", $post, $location);
+                                       fromgplus_post($a, $uid, $item->provider->title, $post, $location);
 
                                        break;
 
@@ -488,10 +486,11 @@ function fromgplus_fetch($a, $uid) {
                                        else
                                                $location = "";
 
-                                       fromgplus_post($a, $uid, "Google+", $post, $location);
-                                       //fromgplus_post($a, $uid, $item->provider->title, $post, $location);
+                                       //fromgplus_post($a, $uid, "Google+", $post, $location);
+                                       fromgplus_post($a, $uid, $item->provider->title, $post, $location);
                                        break;
                        }
+               }
        }
        if ($lastdate != 0)
                set_pconfig($uid,'fromgplus','lastdate', $lastdate);
index 5b2b3bf6ee45e4a924fe381e54cb9037f88003d3..f9459b5a1fce207704927c4be83e862e9535b716 100644 (file)
@@ -230,7 +230,7 @@ function gpluspost_send(&$a,&$b) {
                return;
 
        // if post comes from Google+ don't send it back
-       if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') and ($b['app'] == "Google+"))
+       if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') and (($b['app'] == "Google+") OR ($b["extid"] == NETWORK_GPLUS)))
                return;
 
        if (!gpluspost_nextscripts()) {
index 0e6c9c91c8477cebadd19a2a9c9f757bf397f518..b413f59e522387bdcf45ff4f95b79af463b6f95a 100644 (file)
@@ -433,9 +433,6 @@ function pumpio_send(&$a,&$b) {
 
                $title = trim($b['title']);
 
-               //if ($title != '')
-               //      $title = "<h4>".$title."</h4>";
-
                $content = bbcode($b['body'], false, false, 4);
 
                // Enhance the way, videos are displayed
@@ -502,6 +499,10 @@ function pumpio_send(&$a,&$b) {
                $success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
 
                if($success) {
+
+                       if ($user->generator->displayName)
+                               set_pconfig($b["uid"], "pumpio", "application_name", $user->generator->displayName);
+
                        $post_id = $user->object->id;
                        logger('pumpio_send '.$username.': success '.$post_id);
                        if($post_id AND $iscomment) {
@@ -672,8 +673,12 @@ function pumpio_fetchtimeline(&$a, $uid) {
        $hostname = get_pconfig($uid, 'pumpio','host');
        $username = get_pconfig($uid, "pumpio", "user");
 
-       $application_name  = get_config('pumpio', 'application_name');
-
+       //  get the application name for the pump.io app
+       //  1st try personal config, then system config and fallback to the
+       //  hostname of the node if neither one is set.
+       $application_name  = get_pconfig( $uid, 'pumpio', 'application_name');
+       if ($application_name == "")
+               $application_name  = get_config('pumpio', 'application_name');
        if ($application_name == "")
                $application_name = $a->get_hostname();
 
index 6713842ef9c60965819bf816123ef705f85927eb..a4b539f4d797ed92d2def54bd085c64b27cd7d23 100644 (file)
@@ -606,6 +606,10 @@ function statusnet_post_hook(&$a,&$b) {
                        //$result = $dent->post('statuses/update', $postdata);
                        logger('statusnet_post send, result: ' . print_r($result, true).
                                "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b, true)."\nPost Data: ".print_r($postdata, true));
+
+                       if ($result->source)
+                               set_pconfig($b["uid"], "statusnet", "application_name", strip_tags($result->source));
+
                        if ($result->error) {
                                logger('Send to StatusNet failed: "'.$result->error.'"');
                        } elseif ($iscomment) {
index f00767036d195534e83a256d656b0ca9c9086ed6..16b3ea46142cdb09429e8a7add4b982f492f901d 100644 (file)
@@ -506,6 +506,10 @@ function twitter_post_hook(&$a,&$b) {
                        unlink($tempfile);
 
                        logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG);
+
+                       if ($result->source)
+                               set_config("twitter", "application_name", strip_tags($result->source));
+
                        if ($result->errors OR $result->error) {
                                logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
 
@@ -531,6 +535,10 @@ function twitter_post_hook(&$a,&$b) {
 
                        $result = $tweet->post($url, $post);
                        logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
+
+                       if ($result->source)
+                               set_config("twitter", "application_name", strip_tags($result->source));
+
                        if ($result->errors) {
                                logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');