Only query the last item on public contacts

This commit is contained in:
Michael 2020-08-05 08:24:01 +00:00
parent 3a4be3d5f4
commit 2280f52945

View file

@ -1235,8 +1235,10 @@ class Contact
$data['gsid'] = GServer::getID($data['baseurl']); $data['gsid'] = GServer::getID($data['baseurl']);
} }
$data['last-item'] = Probe::getLastUpdate($data); if ($uid == 0) {
Logger::info('Fetched last item', ['url' => $data['url'], 'last-item' => $data['last-item']]); $data['last-item'] = Probe::getLastUpdate($data);
Logger::info('Fetched last item', ['url' => $data['url'], 'last-item' => $data['last-item']]);
}
if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $data['url']) && !$in_loop) { if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $data['url']) && !$in_loop) {
$contact_id = self::getIdForURL($data["alias"], $uid, false, $default, true); $contact_id = self::getIdForURL($data["alias"], $uid, false, $default, true);
@ -1267,7 +1269,6 @@ class Contact
'poco' => $data['poco'] ?? '', 'poco' => $data['poco'] ?? '',
'baseurl' => $data['baseurl'] ?? '', 'baseurl' => $data['baseurl'] ?? '',
'gsid' => $data['gsid'] ?? null, 'gsid' => $data['gsid'] ?? null,
'last-item' => $data['last-item'] ?: DBA::NULL_DATETIME,
'name-date' => DateTimeFormat::utcNow(), 'name-date' => DateTimeFormat::utcNow(),
'uri-date' => DateTimeFormat::utcNow(), 'uri-date' => DateTimeFormat::utcNow(),
'avatar-date' => DateTimeFormat::utcNow(), 'avatar-date' => DateTimeFormat::utcNow(),
@ -1276,6 +1277,10 @@ class Contact
'readonly' => 0, 'readonly' => 0,
'pending' => 0]; 'pending' => 0];
if (!empty($data['last-item'])) {
$fields['last-item'] = $data['last-item'];
}
$condition = ['nurl' => Strings::normaliseLink($data["url"]), 'uid' => $uid, 'deleted' => false]; $condition = ['nurl' => Strings::normaliseLink($data["url"]), 'uid' => $uid, 'deleted' => false];
// Before inserting we do check if the entry does exist now. // Before inserting we do check if the entry does exist now.
@ -1333,7 +1338,7 @@ class Contact
$updated[$field] = ($data[$field] ?? '') ?: $contact[$field]; $updated[$field] = ($data[$field] ?? '') ?: $contact[$field];
} }
if ($contact['last-item'] < $data['last-item']) { if (!empty($data['last-item']) && ($contact['last-item'] < $data['last-item'])) {
$updated['last-item'] = $data['last-item']; $updated['last-item'] = $data['last-item'];
} }