Constantly updating public contacts

This commit is contained in:
Michael 2019-06-23 09:27:40 +00:00
parent 5306622225
commit 857469d16a
3 changed files with 50 additions and 12 deletions

View file

@ -117,6 +117,9 @@ class Cron
// Poll contacts
self::pollContacts($parameter, $generation);
// Update contact information
self::updatePublicContacts();
Logger::log('cron: end');
Config::set('system', 'last_cron', time());
@ -124,6 +127,26 @@ class Cron
return;
}
/**
* @brief Update public contacts
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function updatePublicContacts() {
$count = 0;
$last_updated = DateTimeFormat::utc('now - 1 months');
$condition = ["`network` IN (?, ?, ?, ?) AND `uid` = ? AND NOT `self` AND `last-update` < ?",
Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, 0, $last_updated];
$total = DBA::count('contact', $condition);
$contacts = DBA::select('contact', ['id'], $condition, ['limit' => 1000]);
while ($contact = DBA::fetch($contacts)) {
Worker::add(PRIORITY_LOW, "UpdateContact", $contact['id'], 'force');
++$count;
}
Logger::info('Initiated update for public contacts', ['interval' => $count, 'total' => $total]);
DBA::close($contacts);
}
/**
* @brief Poll contacts for unreceived messages
*