Merge pull request #11573 from annando/no-local

Don't touch local avatars
This commit is contained in:
Tobias Diekershoff 2022-05-29 10:10:40 +02:00 committed by GitHub
commit 92bf5213cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -93,13 +93,16 @@ HELP;
} }
$fields = ['id', 'avatar', 'photo', 'thumb', 'micro', 'uri-id', 'url', 'avatar', 'network']; $fields = ['id', 'avatar', 'photo', 'thumb', 'micro', 'uri-id', 'url', 'avatar', 'network'];
$condition = ["`avatar` != ? AND `photo` LIKE ? AND `uid` = ? AND `uri-id` != ? AND NOT `uri-id` IS NULL AND NOT `network` IN (?, ?)", $condition = ["NOT `self` AND `avatar` != ? AND `photo` LIKE ? AND `uid` = ? AND `uri-id` != ? AND NOT `uri-id` IS NULL AND NOT `network` IN (?, ?)",
'', $this->baseurl->get() . '/photo/%', 0, 0, Protocol::MAIL, Protocol::FEED]; '', $this->baseurl->get() . '/photo/%', 0, 0, Protocol::MAIL, Protocol::FEED];
$count = 0; $count = 0;
$total = $this->dba->count('contact', $condition); $total = $this->dba->count('contact', $condition);
$contacts = $this->dba->select('contact', $fields, $condition, ['order' => ['id']]); $contacts = $this->dba->select('contact', $fields, $condition, ['order' => ['id']]);
while ($contact = $this->dba->fetch($contacts)) { while ($contact = $this->dba->fetch($contacts)) {
if (Contact::isLocal($contact['url'])) {
continue;
}
$this->out(++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t", false); $this->out(++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t", false);
$resourceid = Photo::ridFromURI($contact['photo']); $resourceid = Photo::ridFromURI($contact['photo']);
if (empty($resourceid)) { if (empty($resourceid)) {
@ -115,7 +118,7 @@ HELP;
$photos = $this->dba->p("SELECT `resource-id`, MAX(`contact-id`) AS `contact-id` FROM `photo` WHERE `contact-id` != ? AND `photo-type` = ? GROUP BY `resource-id`;", 0, Photo::CONTACT_AVATAR); $photos = $this->dba->p("SELECT `resource-id`, MAX(`contact-id`) AS `contact-id` FROM `photo` WHERE `contact-id` != ? AND `photo-type` = ? GROUP BY `resource-id`;", 0, Photo::CONTACT_AVATAR);
while ($photo = $this->dba->fetch($photos)) { while ($photo = $this->dba->fetch($photos)) {
$contact = Contact::getById($photo['contact-id'], $fields); $contact = Contact::getById($photo['contact-id'], $fields);
if (empty($contact) || in_array($contact['network'], [Protocol::MAIL, Protocol::FEED])) { if (empty($contact) || in_array($contact['network'], [Protocol::MAIL, Protocol::FEED]) || Contact::isLocal($contact['url'])) {
continue; continue;
} }
$this->out(++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t", false); $this->out(++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t", false);