mirror of
https://github.com/friendica/friendica
synced 2024-05-30 20:08:20 +02:00
Merge pull request #9032 from annando/local-access
Some more local network access are removed
This commit is contained in:
commit
17dbffe824
|
@ -1973,8 +1973,7 @@ class BBCode
|
|||
*/
|
||||
private static function bbCodeMention2DiasporaCallback($match)
|
||||
{
|
||||
$contact = Contact::getByURL($match[3], null, ['addr']);
|
||||
|
||||
$contact = Contact::getByURL($match[3], false, ['addr']);
|
||||
if (empty($contact['addr'])) {
|
||||
return $match[0];
|
||||
}
|
||||
|
|
|
@ -1560,7 +1560,7 @@ class Contact
|
|||
*/
|
||||
public static function updateAvatar(int $cid, string $avatar, bool $force = false)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['uid', 'avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid, 'self' => false]);
|
||||
$contact = DBA::selectFirst('contact', ['uid', 'avatar', 'photo', 'thumb', 'micro', 'nurl', 'url'], ['id' => $cid, 'self' => false]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1576,6 +1576,27 @@ class Contact
|
|||
return;
|
||||
}
|
||||
|
||||
$local_uid = User::getIdForURL($contact['url']);
|
||||
if (!empty($local_uid)) {
|
||||
$fields = self::selectFirst(['avatar', 'avatar-date', 'photo', 'thumb', 'micro'], ['self' => true, 'uid' => $local_uid]);
|
||||
}
|
||||
|
||||
// Replace cached avatar pictures from the default avatar with the default avatars in different sizes
|
||||
if (strpos($avatar, self::DEFAULT_AVATAR_PHOTO)) {
|
||||
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
|
||||
'photo' => DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO,
|
||||
'thumb' => DI::baseUrl() . self::DEFAULT_AVATAR_THUMB,
|
||||
'micro' => DI::baseUrl() . self::DEFAULT_AVATAR_MICRO];
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
if ($fields['photo'] . $fields['thumb'] . $fields['micro'] != $contact['photo'] . $contact['thumb'] . $contact['micro']) {
|
||||
DBA::update('contact', $fields, ['id' => $cid]);
|
||||
Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'album' => Photo::CONTACT_PHOTOS]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [
|
||||
$contact['photo'] ?? '',
|
||||
$contact['thumb'] ?? '',
|
||||
|
@ -1584,16 +1605,6 @@ class Contact
|
|||
|
||||
$update = ($contact['avatar'] != $avatar) || $force;
|
||||
|
||||
if (strpos($avatar, self::DEFAULT_AVATAR_PHOTO)) {
|
||||
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
|
||||
'photo' => DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO,
|
||||
'thumb' => DI::baseUrl() . self::DEFAULT_AVATAR_THUMB,
|
||||
'micro' => DI::baseUrl() . self::DEFAULT_AVATAR_MICRO];
|
||||
DBA::update('contact', $fields, ['id' => $cid]);
|
||||
Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'album' => Photo::CONTACT_PHOTOS]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$update) {
|
||||
foreach ($data as $image_uri) {
|
||||
$image_rid = Photo::ridFromURI($image_uri);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -103,6 +103,15 @@ class OnePoll
|
|||
return;
|
||||
}
|
||||
|
||||
// Don't poll local contacts
|
||||
if (User::getIdForURL($contact['url'])) {
|
||||
Logger::info('Local contacts are not polled', ['id' => $contact['id']]);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't poll AP contacts by now
|
||||
if ($protocol === Protocol::ACTIVITYPUB) {
|
||||
Logger::log("Don't poll AP contact");
|
||||
|
|
Loading…
Reference in a new issue