mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update AvatarObserver, add logic to delete avatars stored in S3
This commit is contained in:
parent
f7e72d7c62
commit
9eafc31e6f
1 changed files with 10 additions and 0 deletions
|
@ -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 a new issue