+ } else {
+ // Only update federated accounts that hadn't failed before and hadn't been updated recently
+ $update = in_array($contact['network'], Protocol::FEDERATED) && !$contact['failed']
+ && ((time() - strtotime($contact['updated']) > 86400));
+ if ($update) {
+ $curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
+ $update = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
+ Logger::debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
+ }
+ if ($update) {
+ try {
+ UpdateContact::add(Worker::PRIORITY_LOW, $id);
+ Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
+ } catch (\InvalidArgumentException $e) {
+ Logger::notice($e->getMessage(), ['id' => $id, 'contact' => $contact]);
+ }
+ } else {
+ Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
+ }
+ }
+ if (!empty($mimetext) && ($mime[0] != 'image') && ($mimetext != 'application/octet-stream')) {
+ Logger::info('Unexpected Content-Type', ['mime' => $mimetext, 'url' => $url]);
+ $mimetext = '';
+ } if (!empty($mimetext)) {
+ Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);