From 99e96d89230b2d3b9db18816a95d37084ee05caf Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 13 Dec 2020 16:40:50 +0000 Subject: [PATCH] Added forgotten uid --- twitter/twitter.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index dea7e4df..ba9ac287 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1005,6 +1005,7 @@ function twitter_parse_link(App $a, array &$b) */ function twitter_do_mirrorpost(App $a, $uid, $post) { + $datarray['uid'] = $uid; $datarray['extid'] = 'twitter::' . $post->id; $datarray['title'] = ''; @@ -1065,6 +1066,14 @@ function twitter_fetchtimeline(App $a, $uid) $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); + // Ensure to have the own contact + try { + twitter_fetch_own_contact($a, $uid); + } catch (TwitterOAuthException $e) { + Logger::warning('Error fetching own contact', ['uid' => $uid, 'message' => $e->getMessage()]); + return; + } + $parameters = ["exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended", "include_ext_alt_text" => true]; $first_time = ($lastid == ""); @@ -1228,12 +1237,16 @@ function twitter_fetch_contact($uid, $data, $create_user) if (!empty($cid)) { DBA::update('contact', $fields, ['id' => $cid]); Contact::updateAvatar($cid, $avatar); + } else { + Logger::warning('No contact found', ['fields' => $fields]); } $contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]); - if (!DBA::isResult($contact) && !$create_user) { + if (!DBA::isResult($contact) && empty($cid)) { Logger::warning('User contact not found', ['uid' => $uid, 'twitter-id' => $data->id_str]); return 0; + } else { + return $cid; } if (!DBA::isResult($contact)) { -- 2.39.5