Blocked servers can now be deleted
This commit is contained in:
parent
bbb5440144
commit
a151cf450a
|
@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Model\GServer;
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
|
||||||
|
@ -33,11 +34,14 @@ class UpdateBlockedServers
|
||||||
*/
|
*/
|
||||||
public static function execute()
|
public static function execute()
|
||||||
{
|
{
|
||||||
Logger::debug('Update blocked servers - start');
|
Logger::info('Update blocked servers - start');
|
||||||
$gservers = DBA::select('gserver', ['id', 'url', 'blocked']);
|
$gservers = DBA::select('gserver', ['id', 'url', 'blocked']);
|
||||||
|
$changed = 0;
|
||||||
|
$unchanged = 0;
|
||||||
while ($gserver = DBA::fetch($gservers)) {
|
while ($gserver = DBA::fetch($gservers)) {
|
||||||
$blocked = Network::isUrlBlocked($gserver['url']);
|
$blocked = Network::isUrlBlocked($gserver['url']);
|
||||||
if (!is_null($gserver['blocked']) && ($blocked == $gserver['blocked'])) {
|
if (!is_null($gserver['blocked']) && ($blocked == $gserver['blocked'])) {
|
||||||
|
$unchanged++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +50,15 @@ class UpdateBlockedServers
|
||||||
} else {
|
} else {
|
||||||
GServer::setUnblockedById($gserver['id']);
|
GServer::setUnblockedById($gserver['id']);
|
||||||
}
|
}
|
||||||
|
$changed++;
|
||||||
}
|
}
|
||||||
DBA::close($gservers);
|
DBA::close($gservers);
|
||||||
Logger::debug('Update blocked servers - done');
|
Logger::info('Update blocked servers - done', ['changed' => $changed, 'unchanged' => $unchanged]);
|
||||||
|
|
||||||
|
if (DI::config()->get('system', 'delete-blocked-servers')) {
|
||||||
|
Logger::info('Delete blocked servers - start');
|
||||||
|
DBA::p("DELETE FROM `gserver` WHERE `blocked` AND NOT EXISTS(SELECT `gsid` FROM `inbox-status` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `contact` WHERE gsid= `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `apcontact` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `delivery-queue` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gsid` FROM `diaspora-contact` WHERE `gsid` = `gserver`.`id`) AND NOT EXISTS(SELECT `gserver-id` FROM `gserver-tag` WHERE `gserver-id` = `gserver`.`id`)");
|
||||||
|
Logger::info('Delete blocked servers - done', ['rows' => DBA::affectedRows()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,10 @@ return [
|
||||||
// Periodically delete waiting database processes.
|
// Periodically delete waiting database processes.
|
||||||
'delete_sleeping_processes' => false,
|
'delete_sleeping_processes' => false,
|
||||||
|
|
||||||
|
// delete-blocked-servers (Boolean)
|
||||||
|
// Delete blocked servers if possible.
|
||||||
|
'delete-blocked-servers' => false,
|
||||||
|
|
||||||
// dice_profiler_threshold (Float)
|
// dice_profiler_threshold (Float)
|
||||||
// For profiling Dice class creation (0 = disabled, >0 = seconds threshold for profiling)
|
// For profiling Dice class creation (0 = disabled, >0 = seconds threshold for profiling)
|
||||||
'dice_profiler_threshold' => 0.5,
|
'dice_profiler_threshold' => 0.5,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user