*/
class GContact
{
+ /**
+ * No discovery of followers/followings
+ */
+ const DISCOVERY_NONE = 0;
+ /**
+ * Only discover followers/followings from direct contacts
+ */
+ const DISCOVERY_DIRECT = 1;
+ /**
+ * Recursive discovery of followers/followings
+ */
+ const DISCOVERY_RECURSIVE = 2;
+
/**
* Search global contact table by nick or name
*
// Ignore results that look strange.
// For historic reasons the gcontact table does contain some garbage.
- if (!empty($urlparts['query']) || !empty($urlparts['fragment'])) {
+ if (empty($result['nurl']) || !empty($urlparts['query']) || !empty($urlparts['fragment'])) {
continue;
}
$gcontacts[] = Contact::getDetailsByURL($result['nurl'], local_user());
}
+ DBA::close($results);
return $gcontacts;
}
PortableContact::loadWorker(0, 0, 0, $base);
}
}
+ DBA::close($contacts);
}
/**
$items = $outbox['orderedItems'];
} elseif (!empty($outbox['first']['orderedItems'])) {
$items = $outbox['first']['orderedItems'];
- } elseif (!empty($outbox['first']['href'])) {
+ } elseif (!empty($outbox['first']['href']) && ($outbox['first']['href'] != $feed)) {
self::updateFromOutbox($outbox['first']['href'], $data);
return;
} elseif (!empty($outbox['first'])) {
- if (is_string($outbox['first'])) {
+ if (is_string($outbox['first']) && ($outbox['first'] != $feed)) {
self::updateFromOutbox($outbox['first'], $data);
} else {
Logger::warning('Unexpected data', ['outbox' => $outbox]);
foreach ($contacts as $contact) {
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(($contact))]);
if (DBA::isResult($gcontact)) {
+ $fields = [];
if (in_array($contact, $followers)) {
$fields = ['gcid' => $gcid, 'follower-gcid' => $gcontact['id']];
} elseif (in_array($contact, $followings)) {
$fields = ['gcid' => $gcontact['id'], 'follower-gcid' => $gcid];
}
- Logger::info('Set relation between contacts', $fields);
- DBA::update('gfollower', ['deleted' => false], $fields, true);
- continue;
+
+ if (!empty($fields)) {
+ Logger::info('Set relation between contacts', $fields);
+ DBA::update('gfollower', ['deleted' => false], $fields, true);
+ continue;
+ }
}
if (!Network::isUrlBlocked($contact)) {
Logger::info('Discover new AP contact', ['url' => $contact]);
- Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact);
+ Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact, 'nodiscover');
} else {
Logger::info('No discovery, the URL is blocked.', ['url' => $contact]);
}
}
if (!Network::isUrlBlocked($entry['value'])) {
Logger::info('Discover new PoCo contact', ['url' => $entry['value']]);
- Worker::add(PRIORITY_LOW, 'UpdateGContact', $entry['value']);
+ Worker::add(PRIORITY_LOW, 'UpdateGContact', $entry['value'], 'nodiscover');
} else {
Logger::info('No discovery, the URL is blocked.', ['url' => $entry['value']]);
}