Merge pull request #13998 from annando/probe-hide

Fix: "unsearchable" is now stored
This commit is contained in:
Tobias Diekershoff 2024-03-15 07:24:13 +01:00 committed by GitHub
commit b8396daca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 6 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2024.03-rc (Yellow Archangel)
-- DB_UPDATE_VERSION 1556
-- DB_UPDATE_VERSION 1557
-- ------------------------------------------

View file

@ -376,6 +376,9 @@ class APContact
}
$apcontact['discoverable'] = JsonLD::fetchElement($compacted, 'toot:discoverable', '@value');
if (is_null($apcontact['discoverable']) && ($apcontact['type'] == 'Application')) {
$apcontact['discoverable'] = false;
}
if (!empty($apcontact['photo'])) {
$apcontact['photo'] = Network::addBasePath($apcontact['photo'], $apcontact['url']);

View file

@ -1130,7 +1130,7 @@ class Contact
{
// Always unarchive the relay contact entry
if (!empty($contact['batch']) && !empty($contact['term-date']) && ($contact['term-date'] > DBA::NULL_DATETIME)) {
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false, 'unsearchable' => true];
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
if (!DBA::exists('contact', array_merge($condition, $fields))) {
self::update($fields, $condition);

View file

@ -118,7 +118,8 @@ class Probe
'following', 'followers', 'inbox', 'outbox', 'sharedinbox',
'priority', 'network', 'pubkey', 'manually-approve', 'baseurl', 'gsid'];
$numeric_fields = ['gsid', 'hide', 'account-type', 'manually-approve'];
$numeric_fields = ['gsid', 'account-type'];
$boolean_fields = ['hide', 'manually-approve'];
if (!empty($data['photo'])) {
$data['photo'] = Network::addBasePath($data['photo'], $data['url']);
@ -134,6 +135,8 @@ class Probe
if (isset($data[$field])) {
if (in_array($field, $numeric_fields)) {
$newdata[$field] = (int)$data[$field];
} elseif (in_array($field, $boolean_fields)) {
$newdata[$field] = (bool)$data[$field];
} else {
$newdata[$field] = trim($data[$field]);
}

View file

@ -246,13 +246,14 @@ class Relay
$fields['contact-type'] = Contact::TYPE_RELAY;
Logger::info('Assigning missing data for relay contact', ['server' => $gserver['url'], 'id' => $old['id']]);
}
} elseif (empty($fields)) {
} elseif (empty($fields) && $old['unsearchable']) {
Logger::info('No content to update, quitting', ['server' => $gserver['url']]);
return;
}
if (DBA::isResult($old)) {
$fields['updated'] = DateTimeFormat::utcNow();
$fields['updated'] = DateTimeFormat::utcNow();
$fields['unsearchable'] = true;
Logger::info('Update relay contact', ['server' => $gserver['url'], 'id' => $old['id'], 'fields' => $fields]);
Contact::update($fields, ['id' => $old['id']], $old);
@ -265,6 +266,7 @@ class Relay
'rel' => Contact::FOLLOWER, 'blocked' => false,
'pending' => false, 'writable' => true,
'gsid' => $gserver['id'],
'unsearchable' => true,
'baseurl' => $gserver['url'], 'contact-type' => Contact::TYPE_RELAY];
$fields = array_merge($default, $fields);

View file

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1556);
define('DB_UPDATE_VERSION', 1557);
}
return [

View file

@ -63,6 +63,7 @@ use Friendica\Protocol\Activity;
use Friendica\Protocol\Delivery;
use Friendica\Security\PermissionSet\Repository\PermissionSet;
use Friendica\Util\DateTimeFormat;
use Friendica\Worker\UpdateContact;
// Post-update script of PR 5751
function update_1298()
@ -1447,3 +1448,13 @@ function update_1556()
return Update::SUCCESS;
}
function update_1557()
{
$contacts = DBA::select('account-view', ['id'], ['platform' => 'friendica', 'contact-type' => Contact::TYPE_RELAY]);
while ($contact = DBA::fetch($contacts)) {
UpdateContact::add(Worker::PRIORITY_LOW, $contact['id']);
}
DBA::close($contacts);
return Update::SUCCESS;
}