mirror of https://github.com/pixelfed/pixelfed
Merge pull request #5125 from pixelfed/staging
Add /api/v1/instance/peers API endpoint, disabled by defaultpull/5259/head
commit
d4e8ca3086
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Instance;
|
||||||
|
use App\Jobs\InstancePipeline\FetchNodeinfoPipeline;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use function Laravel\Prompts\progress;
|
||||||
|
|
||||||
|
class WeeklyInstanceScan extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'app:weekly-instance-scan';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Scan instance nodeinfo';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if ((bool) config_cache('federation.activitypub.enabled') == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$users = progress(
|
||||||
|
label: 'Updating instance stats...',
|
||||||
|
steps: Instance::all(),
|
||||||
|
callback: fn ($instance) => $this->updateInstanceStats($instance),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function updateInstanceStats($instance)
|
||||||
|
{
|
||||||
|
FetchNodeinfoPipeline::dispatch($instance)->onQueue('intbg');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('instances', function (Blueprint $table) {
|
||||||
|
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||||
|
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||||
|
if (! array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||||
|
$table->index('nodeinfo_last_fetched');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('instances', function (Blueprint $table) {
|
||||||
|
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||||
|
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||||
|
if (array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||||
|
$table->dropIndex('instances_nodeinfo_last_fetched_index');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue