Fix: "unsearchable" is now stored

This commit is contained in:
Michael 2024-03-15 06:07:47 +00:00
parent 57187f26ae
commit eaddf5318a
7 changed files with 25 additions and 6 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2024.03-rc (Yellow Archangel) -- 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'); $apcontact['discoverable'] = JsonLD::fetchElement($compacted, 'toot:discoverable', '@value');
if (is_null($apcontact['discoverable']) && ($apcontact['type'] == 'Application')) {
$apcontact['discoverable'] = false;
}
if (!empty($apcontact['photo'])) { if (!empty($apcontact['photo'])) {
$apcontact['photo'] = Network::addBasePath($apcontact['photo'], $apcontact['url']); $apcontact['photo'] = Network::addBasePath($apcontact['photo'], $apcontact['url']);

View File

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

View File

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

View File

@ -246,13 +246,14 @@ class Relay
$fields['contact-type'] = Contact::TYPE_RELAY; $fields['contact-type'] = Contact::TYPE_RELAY;
Logger::info('Assigning missing data for relay contact', ['server' => $gserver['url'], 'id' => $old['id']]); 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']]); Logger::info('No content to update, quitting', ['server' => $gserver['url']]);
return; return;
} }
if (DBA::isResult($old)) { 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]); Logger::info('Update relay contact', ['server' => $gserver['url'], 'id' => $old['id'], 'fields' => $fields]);
Contact::update($fields, ['id' => $old['id']], $old); Contact::update($fields, ['id' => $old['id']], $old);
@ -265,6 +266,7 @@ class Relay
'rel' => Contact::FOLLOWER, 'blocked' => false, 'rel' => Contact::FOLLOWER, 'blocked' => false,
'pending' => false, 'writable' => true, 'pending' => false, 'writable' => true,
'gsid' => $gserver['id'], 'gsid' => $gserver['id'],
'unsearchable' => true,
'baseurl' => $gserver['url'], 'contact-type' => Contact::TYPE_RELAY]; 'baseurl' => $gserver['url'], 'contact-type' => Contact::TYPE_RELAY];
$fields = array_merge($default, $fields); $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 // This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1556); define('DB_UPDATE_VERSION', 1557);
} }
return [ return [

View File

@ -63,6 +63,7 @@ use Friendica\Protocol\Activity;
use Friendica\Protocol\Delivery; use Friendica\Protocol\Delivery;
use Friendica\Security\PermissionSet\Repository\PermissionSet; use Friendica\Security\PermissionSet\Repository\PermissionSet;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Worker\UpdateContact;
// Post-update script of PR 5751 // Post-update script of PR 5751
function update_1298() function update_1298()
@ -1447,3 +1448,13 @@ function update_1556()
return Update::SUCCESS; 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;
}