mirror of https://github.com/pixelfed/pixelfed.git
Update AvatarObserver, add logic to delete avatars stored in S3
This commit is contained in:
parent
f7e72d7c62
commit
9eafc31e6f
|
@ -3,6 +3,8 @@
|
|||
namespace App\Observers;
|
||||
|
||||
use App\Avatar;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AvatarObserver
|
||||
{
|
||||
|
@ -54,6 +56,14 @@ class AvatarObserver
|
|||
) {
|
||||
@unlink($path);
|
||||
}
|
||||
|
||||
if($avatar->cdn_url) {
|
||||
$disk = Storage::disk(config('filesystems.cloud'));
|
||||
$base = Str::startsWith($avatar->media_path, 'cache/avatars/');
|
||||
if($base && $disk->exists($avatar->media_path)) {
|
||||
$disk->delete($avatar->media_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue