mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 09:43:16 +00:00
Update DeleteAccountPipeline
This commit is contained in:
parent
2b76db6421
commit
2378376595
1 changed files with 33 additions and 7 deletions
|
@ -30,6 +30,7 @@ use App\{
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
Status,
|
Status,
|
||||||
User,
|
User,
|
||||||
|
UserDevice,
|
||||||
UserFilter,
|
UserFilter,
|
||||||
UserSetting,
|
UserSetting,
|
||||||
};
|
};
|
||||||
|
@ -66,7 +67,9 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::transaction(function() use ($user) {
|
||||||
if($user->profile) {
|
if($user->profile) {
|
||||||
$avatar = $user->profile->avatar;
|
$avatar = $user->profile->avatar;
|
||||||
|
|
||||||
|
@ -90,7 +93,9 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
Follower::whereProfileId($id)->orWhere('following_id', $id)->forceDelete();
|
Follower::whereProfileId($id)->orWhere('following_id', $id)->forceDelete();
|
||||||
|
|
||||||
Like::whereProfileId($id)->forceDelete();
|
Like::whereProfileId($id)->forceDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
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 = $media->media_path;
|
$path = $media->media_path;
|
||||||
|
@ -103,31 +108,52 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
$media->forceDelete();
|
$media->forceDelete();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::transaction(function() use ($user) {
|
||||||
Mention::whereProfileId($user->profile->id)->forceDelete();
|
Mention::whereProfileId($user->profile->id)->forceDelete();
|
||||||
|
Notification::whereProfileId($user->profile->id)->orWhere('actor_id', $user->profile->id)->forceDelete();
|
||||||
|
});
|
||||||
|
|
||||||
Notification::whereProfileId($id)->orWhere('actor_id', $id)->forceDelete();
|
DB::transaction(function() use ($user) {
|
||||||
|
|
||||||
Status::whereProfileId($user->profile->id)->forceDelete();
|
Status::whereProfileId($user->profile->id)->forceDelete();
|
||||||
|
|
||||||
Report::whereUserId($user->id)->forceDelete();
|
Report::whereUserId($user->id)->forceDelete();
|
||||||
$this->deleteProfile($user);
|
$this->deleteProfile($user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteProfile($user) {
|
protected function deleteProfile($user) {
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
Profile::whereUserId($user->id)->delete();
|
Profile::whereUserId($user->id)->delete();
|
||||||
$this->deleteUser($user);
|
$this->deleteUserSettings($user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteUser($user) {
|
protected function deleteUserSettings($user) {
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
|
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();
|
||||||
$user->forceDelete();
|
$this->deleteUserColumns($user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function deleteUserColumns($user)
|
||||||
|
{
|
||||||
|
DB::transaction(function() use ($user) {
|
||||||
|
$user->status = 'deleted';
|
||||||
|
$user->name = 'deleted';
|
||||||
|
$user->email = $user->id;
|
||||||
|
$user->password = '';
|
||||||
|
$user->remember_token = null;
|
||||||
|
$user->is_admin = false;
|
||||||
|
$user->{'2fa_enabled'} = false;
|
||||||
|
$user->{'2fa_secret'} = null;
|
||||||
|
$user->{'2fa_backup_codes'} = null;
|
||||||
|
$user->{'2fa_setup_at'} = null;
|
||||||
|
$user->save();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue