]> git.mxchange.org Git - friendica-addons.git/commitdiff
skip duplicate posts when importing hometimeline
authorJohannes Schwab <mail@jschwab.org>
Sat, 18 Jul 2015 09:03:58 +0000 (11:03 +0200)
committerJohannes Schwab <mail@jschwab.org>
Sun, 19 Jul 2015 10:37:58 +0000 (12:37 +0200)
twitter/twitter.php

index c87f4a01e494e5f24626f17ee04c659a1f4ace78..41bfdaa71a4a2644b7ff811213bae92137e154d8 100644 (file)
@@ -1548,9 +1548,15 @@ function twitter_fetchhometimeline($a, $uid) {
        $otoken  = get_pconfig($uid, 'twitter', 'oauthtoken');
        $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
        $create_user = get_pconfig($uid, 'twitter', 'create_user');
+       $mirror_posts = get_pconfig($uid, 'twitter', 'mirror_posts');
 
        logger("twitter_fetchhometimeline: Fetching for user ".$uid, LOGGER_DEBUG);
 
+       $application_name  = get_config('twitter', 'application_name');
+
+       if ($application_name == "")
+               $application_name = $a->get_hostname();
+
        require_once('library/twitteroauth.php');
        require_once('include/items.php');
 
@@ -1617,6 +1623,16 @@ function twitter_fetchhometimeline($a, $uid) {
                        if ($first_time)
                                continue;
 
+                       if (stristr($post->source, $application_name) && $post->user->screen_name == $own_id) {
+                               logger("twitter_fetchhometimeline: Skip previously sended post for user ".$uid, LOGGER_DEBUG);
+                               continue;
+                       }
+
+                       if ($mirror_posts && $post->user->screen_name == $own_id && $post->in_reply_to_status_id_str == "") {
+                               logger("twitter_fetchhometimeline: Skip post that will be mirrored for user ".$uid, LOGGER_DEBUG);
+                               continue;
+                       }
+
                        $postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true);
 
                        if (trim($postarray['body']) == "")