- $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
-
- if (strpos($final_dfrn_id, ':') == 1) {
- $final_dfrn_id = substr($final_dfrn_id, 2);
- }
-
- // There are issues with the legacy DFRN transport layer.
- // Since we mostly don't use it anyway, we won't dig into it deeper, but simply ignore it.
- if (empty($final_dfrn_id) || empty($orig_id)) {
- Logger::log('Contact has got no ID - quitting');
- return false;
- }
-
- if ($final_dfrn_id != $orig_id) {
- // did not decode properly - cannot trust this site
- Logger::log('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
-
- // set the last-update so we don't keep polling
- DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
- Contact::markForArchival($contact);
- return false;
- }
-
- $postvars['dfrn_id'] = $idtosend;
- $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
- $postvars['perm'] = 'rw';
-
- return DI::httpRequest()->post($contact['poll'], $postvars)->getBody();
- }
-
- /**
- * Poll Feed/OStatus contacts
- *
- * @param array $contact The personal contact entry
- * @param string $protocol The used protocol of the contact
- * @param string $updated The updated date
- * @return string polled XML
- * @throws \Exception
- */
- private static function pollFeed(array $contact, $protocol, $updated)
- {
- // Upgrading DB fields from an older Friendica version
- // Will only do this once per notify-enabled OStatus contact
- // or if relationship changes
-
- $stat_writeable = $contact['notify'] && ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND);
-
- // Contacts from OStatus are always writable
- if ($protocol === Protocol::OSTATUS) {
- $stat_writeable = 1;
- }
-
- if ($stat_writeable != $contact['writable']) {
- $fields = ['writable' => $stat_writeable];
- DBA::update('contact', $fields, ['id' => $contact['id']]);
- }
-
- // Are we allowed to import from this person?
- if ($contact['rel'] == Contact::FOLLOWER || $contact['blocked']) {
- // set the last-update so we don't keep polling
- DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
- Logger::log('Contact is blocked or only a follower');
- return false;
- }
-
- $cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
- $curlResult = DI::httpRequest()->get($contact['poll'], ['cookiejar' => $cookiejar]);
- unlink($cookiejar);
-
- if ($curlResult->isTimeout()) {
- // set the last-update so we don't keep polling
- self::updateContact($contact, ['failed' => true, 'last-update' => $updated]);
- Contact::markForArchival($contact);
- Logger::log('Contact archived');
- return false;
- }
-
- return $curlResult->getBody();