From 6ce762010e6cb59cb9e53ee0f0751db7afef5caf Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 7 Jun 2020 16:49:47 -0400 Subject: [PATCH] [twitter] Fix contact image handling in twitter_fetch_contact --- twitter/twitter.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index 2f08b457..fc49ce54 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1077,7 +1077,6 @@ function twitter_user_to_contact($data) return -1; } - $avatar = twitter_fix_avatar($data->profile_image_url_https); $baseurl = 'https://twitter.com'; $url = $baseurl . '/' . $data->screen_name; $addr = $data->screen_name . '@twitter.com'; @@ -1092,7 +1091,7 @@ function twitter_user_to_contact($data) 'addr' => $addr, 'location' => $data->location, 'about' => $data->description, - 'photo' => $avatar, + 'photo' => twitter_fix_avatar($data->profile_image_url_https), ]; return $fields; @@ -1106,6 +1105,10 @@ function twitter_fetch_contact($uid, $data, $create_user) return -1; } + // photo comes from twitter_user_to_contact but shouldn't be saved directly in the contact row + $avatar = $fields['photo']; + unset($fields['photo']); + // Update the public contact $pcontact = DBA::selectFirst('contact', ['id'], ['uid' => 0, 'alias' => "twitter::" . $data->id_str]); if (DBA::isResult($pcontact)) { @@ -1116,7 +1119,7 @@ function twitter_fetch_contact($uid, $data, $create_user) if (!empty($cid)) { DBA::update('contact', $fields, ['id' => $cid]); - Contact::updateAvatar($fields['photo'], 0, $cid); + Contact::updateAvatar($avatar, 0, $cid); } $contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]); @@ -1148,7 +1151,7 @@ function twitter_fetch_contact($uid, $data, $create_user) Group::addMember(User::getDefaultGroup($uid), $contact_id); - Contact::updateAvatar($fields['photo'], $uid, $contact_id); + Contact::updateAvatar($avatar, $uid, $contact_id); } else { if ($contact["readonly"] || $contact["blocked"]) { Logger::log("twitter_fetch_contact: Contact '" . $contact["nick"] . "' is blocked or readonly.", Logger::DEBUG); @@ -1164,7 +1167,7 @@ function twitter_fetch_contact($uid, $data, $create_user) $update = true; } - Contact::updateAvatar($fields['photo'], $uid, $contact['id']); + Contact::updateAvatar($avatar, $uid, $contact['id']); if ($contact['name'] != $data->name) { $fields['name-date'] = $fields['uri-date'] = DateTimeFormat::utcNow(); -- 2.39.5