mirror of
https://github.com/friendica/friendica
synced 2024-11-18 15:03:41 +00:00
Avoid locally probing last item via network
This commit is contained in:
parent
29494ea721
commit
eb95314aaa
2 changed files with 13 additions and 0 deletions
|
@ -164,6 +164,11 @@ class User
|
|||
*/
|
||||
public static function getIdForURL(string $url)
|
||||
{
|
||||
// Avoid any database requests when the hostname isn't even part of the url.
|
||||
if (!strpos($url, DI::baseUrl()->getHostname())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]);
|
||||
if (!empty($self['uid'])) {
|
||||
return $self['uid'];
|
||||
|
|
|
@ -2012,6 +2012,14 @@ class Probe
|
|||
*/
|
||||
public static function getLastUpdate(array $data)
|
||||
{
|
||||
$uid = User::getIdForURL($data['url']);
|
||||
if (!empty($uid)) {
|
||||
$contact = Contact::selectFirst(['url', 'last-item'], ['self' => true, 'uid' => $uid]);
|
||||
if (!empty($contact['last-item'])) {
|
||||
return $contact['last-item'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($lastUpdate = self::updateFromNoScrape($data)) {
|
||||
return $lastUpdate;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue