mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 08:13:16 +00:00
Update DeleteAccountPipeline, fix perf issues
This commit is contained in:
parent
37dfb1014f
commit
a9edd93fb5
1 changed files with 11 additions and 23 deletions
|
@ -8,6 +8,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\{
|
use App\{
|
||||||
AccountInterstitial,
|
AccountInterstitial,
|
||||||
|
@ -61,15 +62,10 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
|
$this->deleteUserColumns($user);
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
AccountLog::chunk(200, function($logs) use ($user) {
|
AccountLog::whereItemType('App\User')->whereItemId($user->id)->forceDelete();
|
||||||
foreach($logs as $log) {
|
|
||||||
if($log->user_id == $user->id) {
|
|
||||||
$log->forceDelete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
|
@ -133,14 +129,14 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
$medias = Media::whereUserId($user->id)->get();
|
$medias = Media::whereUserId($user->id)->get();
|
||||||
foreach($medias as $media) {
|
foreach($medias as $media) {
|
||||||
$path = storage_path('app/'.$media->media_path);
|
if(config('pixelfed.cloud_storage')) {
|
||||||
$thumb = storage_path('app/'.$media->thumbnail_path);
|
$disk = Storage::disk(config('filesystems.cloud'));
|
||||||
if(is_file($path)) {
|
$disk->delete($media->media_path);
|
||||||
unlink($path);
|
$disk->delete($media->thumbnail_path);
|
||||||
}
|
|
||||||
if(is_file($thumb)) {
|
|
||||||
unlink($thumb);
|
|
||||||
}
|
}
|
||||||
|
$disk = Storage::disk(config('filesystems.local'));
|
||||||
|
$disk->delete($media->media_path);
|
||||||
|
$disk->delete($media->thumbnail_path);
|
||||||
$media->forceDelete();
|
$media->forceDelete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -165,14 +161,7 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
Status::whereProfileId($user->profile_id)
|
Status::whereProfileId($user->profile_id)->forceDelete();
|
||||||
->cursor()
|
|
||||||
->each(function($status) {
|
|
||||||
AccountInterstitial::where('item_type', 'App\Status')
|
|
||||||
->where('item_id', $status->id)
|
|
||||||
->delete();
|
|
||||||
$status->forceDelete();
|
|
||||||
});
|
|
||||||
Report::whereUserId($user->id)->forceDelete();
|
Report::whereUserId($user->id)->forceDelete();
|
||||||
$this->deleteProfile($user);
|
$this->deleteProfile($user);
|
||||||
});
|
});
|
||||||
|
@ -191,7 +180,6 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
UserDevice::whereUserId($user->id)->forceDelete();
|
UserDevice::whereUserId($user->id)->forceDelete();
|
||||||
UserFilter::whereUserId($user->id)->forceDelete();
|
UserFilter::whereUserId($user->id)->forceDelete();
|
||||||
UserSetting::whereUserId($user->id)->forceDelete();
|
UserSetting::whereUserId($user->id)->forceDelete();
|
||||||
$this->deleteUserColumns($user);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue