mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
commit
19192a2e3f
5 changed files with 51 additions and 51 deletions
|
@ -5,62 +5,56 @@ namespace App\Console\Commands;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\{Media, Status};
|
use App\{Media, Status};
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use App\Services\MediaStorageService;
|
||||||
|
|
||||||
class MediaGarbageCollector extends Command
|
class MediaGarbageCollector extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'media:gc';
|
protected $signature = 'media:gc';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Delete media uploads not attached to any active statuses';
|
protected $description = 'Delete media uploads not attached to any active statuses';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$limit = 20000;
|
$limit = 20000;
|
||||||
|
|
||||||
$gc = Media::doesntHave('status')
|
$gc = Media::whereNull('status_id')
|
||||||
->where('created_at', '<', Carbon::now()->subHours(1)->toDateTimeString())
|
->where('created_at', '<', Carbon::now()->subHours(12)->toDateTimeString())
|
||||||
->orderBy('created_at','asc')
|
->orderBy('created_at','asc')
|
||||||
->take($limit)
|
->take($limit)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$bar = $this->output->createProgressBar($gc->count());
|
$bar = $this->output->createProgressBar($gc->count());
|
||||||
$bar->start();
|
$bar->start();
|
||||||
foreach($gc as $media) {
|
foreach($gc as $media) {
|
||||||
$path = storage_path("app/$media->media_path");
|
MediaStorageService::delete($media);
|
||||||
$thumb = storage_path("app/$media->thumbnail_path");
|
$media->forceDelete();
|
||||||
if(is_file($path)) {
|
$bar->advance();
|
||||||
unlink($path);
|
}
|
||||||
}
|
$bar->finish();
|
||||||
if(is_file($thumb)) {
|
}
|
||||||
unlink($thumb);
|
|
||||||
}
|
|
||||||
$media->forceDelete();
|
|
||||||
$bar->advance();
|
|
||||||
}
|
|
||||||
$bar->finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,9 @@ class InboxValidator implements ShouldQueue
|
||||||
'User-Agent' => 'PixelfedBot v0.1 - https://pixelfed.org',
|
'User-Agent' => 'PixelfedBot v0.1 - https://pixelfed.org',
|
||||||
])->get($actor->remote_url);
|
])->get($actor->remote_url);
|
||||||
$res = json_decode($res->body(), true, 8);
|
$res = json_decode($res->body(), true, 8);
|
||||||
|
if(!$res || empty($res) || !isset($res['publicKey']) || !isset($res['publicKey']['id'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if($res['publicKey']['id'] !== $actor->key_id) {
|
if($res['publicKey']['id'] !== $actor->key_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,9 @@ class InboxWorker implements ShouldQueue
|
||||||
'User-Agent' => 'PixelfedBot v0.1 - https://pixelfed.org',
|
'User-Agent' => 'PixelfedBot v0.1 - https://pixelfed.org',
|
||||||
])->get($actor->remote_url);
|
])->get($actor->remote_url);
|
||||||
$res = json_decode($res->body(), true, 8);
|
$res = json_decode($res->body(), true, 8);
|
||||||
|
if(!$res || empty($res) || !isset($res['publicKey']) || !isset($res['publicKey']['id'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if($res['publicKey']['id'] !== $actor->key_id) {
|
if($res['publicKey']['id'] !== $actor->key_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
BIN
public/js/profile-xl3w8bxy.js
vendored
BIN
public/js/profile-xl3w8bxy.js
vendored
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue