From ca7d448aa568aaa8d9a7abdd3acf4367f015c735 Mon Sep 17 00:00:00 2001 From: Johannes Schwab Date: Sat, 18 Jul 2015 11:03:58 +0200 Subject: [PATCH] skip duplicate posts when importing hometimeline --- twitter/twitter.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/twitter/twitter.php b/twitter/twitter.php index c87f4a01..41bfdaa7 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -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']) == "") -- 2.39.5