1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Merge pull request #3319 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-03-16 20:23:49 -06:00 committed by GitHub
commit 19192a2e3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 53 deletions

View file

@ -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')
->where('created_at', '<', Carbon::now()->subHours(1)->toDateTimeString())
->orderBy('created_at','asc')
->take($limit)
->get();
$bar = $this->output->createProgressBar($gc->count()); $gc = Media::whereNull('status_id')
$bar->start(); ->where('created_at', '<', Carbon::now()->subHours(12)->toDateTimeString())
foreach($gc as $media) { ->orderBy('created_at','asc')
$path = storage_path("app/$media->media_path"); ->take($limit)
$thumb = storage_path("app/$media->thumbnail_path"); ->get();
if(is_file($path)) {
unlink($path); $bar = $this->output->createProgressBar($gc->count());
} $bar->start();
if(is_file($thumb)) { foreach($gc as $media) {
unlink($thumb); MediaStorageService::delete($media);
} $media->forceDelete();
$media->forceDelete(); $bar->advance();
$bar->advance(); }
} $bar->finish();
$bar->finish(); }
}
} }

View file

@ -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;
} }

View file

@ -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;
} }

File diff suppressed because one or more lines are too long

View file

@ -26,7 +26,7 @@
"/js/home-xl3w8bxy.js": "/js/home-xl3w8bxy.js?id=9c4aed07051c46529a7d4140f795a851", "/js/home-xl3w8bxy.js": "/js/home-xl3w8bxy.js?id=9c4aed07051c46529a7d4140f795a851",
"/js/compose-xl3w8bxy.js": "/js/compose-xl3w8bxy.js?id=84580c040776bef4fb2d7d2a43a10022", "/js/compose-xl3w8bxy.js": "/js/compose-xl3w8bxy.js?id=84580c040776bef4fb2d7d2a43a10022",
"/js/post-xl3w8bxy.js": "/js/post-xl3w8bxy.js?id=1147b754b401e714584b7c6ba19e3df1", "/js/post-xl3w8bxy.js": "/js/post-xl3w8bxy.js?id=1147b754b401e714584b7c6ba19e3df1",
"/js/profile-xl3w8bxy.js": "/js/profile-xl3w8bxy.js?id=93a3dcdb3f18fce6e5b3d63fbc5e02a0", "/js/profile-xl3w8bxy.js": "/js/profile-xl3w8bxy.js?id=21b72c974f40d02ead61a218de615bc4",
"/js/dmym-xl3w8bxy.js": "/js/dmym-xl3w8bxy.js?id=3d67875d8ccbdd6afc910c43cced8e37", "/js/dmym-xl3w8bxy.js": "/js/dmym-xl3w8bxy.js?id=3d67875d8ccbdd6afc910c43cced8e37",
"/js/dmyh-xl3w8bxy.js": "/js/dmyh-xl3w8bxy.js?id=649b6c4e1639411791b71ae267f2c42b", "/js/dmyh-xl3w8bxy.js": "/js/dmyh-xl3w8bxy.js?id=649b6c4e1639411791b71ae267f2c42b",
"/js/daci-xl3w8bxy.js": "/js/daci-xl3w8bxy.js?id=a1b350e3cb5a542684b891322bd69116", "/js/daci-xl3w8bxy.js": "/js/daci-xl3w8bxy.js?id=a1b350e3cb5a542684b891322bd69116",