mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 06:23:18 +00:00
Update DeleteAccountPipeline, improve coverage
This commit is contained in:
parent
195c6ba0ea
commit
4870cc3b5d
1 changed files with 24 additions and 2 deletions
|
@ -10,10 +10,11 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use DB;
|
use DB;
|
||||||
use Storage;
|
use Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use App\Services\AccountService;
|
||||||
|
use App\Services\PublicTimelineService;
|
||||||
use App\{
|
use App\{
|
||||||
AccountInterstitial,
|
AccountInterstitial,
|
||||||
AccountLog,
|
AccountLog,
|
||||||
Activity,
|
|
||||||
Avatar,
|
Avatar,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
Collection,
|
Collection,
|
||||||
|
@ -39,6 +40,7 @@ use App\{
|
||||||
ReportComment,
|
ReportComment,
|
||||||
ReportLog,
|
ReportLog,
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
|
StatusArchived,
|
||||||
Status,
|
Status,
|
||||||
Story,
|
Story,
|
||||||
StoryView,
|
StoryView,
|
||||||
|
@ -47,6 +49,7 @@ use App\{
|
||||||
UserFilter,
|
UserFilter,
|
||||||
UserSetting,
|
UserSetting,
|
||||||
};
|
};
|
||||||
|
use App\Models\UserPronoun;
|
||||||
|
|
||||||
class DeleteAccountPipeline implements ShouldQueue
|
class DeleteAccountPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -63,6 +66,7 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
$this->deleteUserColumns($user);
|
$this->deleteUserColumns($user);
|
||||||
|
AccountService::del($user->profile_id);
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
AccountLog::whereItemType('App\User')->whereItemId($user->id)->forceDelete();
|
AccountLog::whereItemType('App\User')->whereItemId($user->id)->forceDelete();
|
||||||
|
@ -75,6 +79,19 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
DB::transaction(function() use ($user) {
|
DB::transaction(function() use ($user) {
|
||||||
if($user->profile) {
|
if($user->profile) {
|
||||||
$avatar = $user->profile->avatar;
|
$avatar = $user->profile->avatar;
|
||||||
|
$path = $avatar->media_path;
|
||||||
|
if(!in_array($path, [
|
||||||
|
'public/avatars/default.jpg',
|
||||||
|
'public/avatars/default.png'
|
||||||
|
])) {
|
||||||
|
if(config('pixelfed.cloud_storage')) {
|
||||||
|
$disk = Storage::disk(config('filesystems.cloud'));
|
||||||
|
$disk->delete($path);
|
||||||
|
}
|
||||||
|
$disk = Storage::disk(config('filesystems.local'));
|
||||||
|
$disk->delete($path);
|
||||||
|
}
|
||||||
|
|
||||||
$avatar->forceDelete();
|
$avatar->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +119,9 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
Bookmark::whereProfileId($id)->forceDelete();
|
Bookmark::whereProfileId($id)->forceDelete();
|
||||||
EmailVerification::whereUserId($user->id)->forceDelete();
|
EmailVerification::whereUserId($user->id)->forceDelete();
|
||||||
StatusHashtag::whereProfileId($id)->delete();
|
StatusHashtag::whereProfileId($id)->delete();
|
||||||
DirectMessage::whereFromId($id)->delete();
|
DirectMessage::whereFromId($id)->orWhereToId($id)->delete();
|
||||||
|
StatusArchived::whereProfileId($id)->delete();
|
||||||
|
UserPronoun::whereProfileId($id)->delete();
|
||||||
FollowRequest::whereFollowingId($id)
|
FollowRequest::whereFollowingId($id)
|
||||||
->orWhere('follower_id', $id)
|
->orWhere('follower_id', $id)
|
||||||
->forceDelete();
|
->forceDelete();
|
||||||
|
@ -157,12 +176,15 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
Contact::whereUserId($user->id)->delete();
|
Contact::whereUserId($user->id)->delete();
|
||||||
HashtagFollow::whereUserId($user->id)->delete();
|
HashtagFollow::whereUserId($user->id)->delete();
|
||||||
OauthClient::whereUserId($user->id)->delete();
|
OauthClient::whereUserId($user->id)->delete();
|
||||||
|
DB::table('oauth_access_tokens')->whereUserId($user->id)->delete();
|
||||||
|
DB::table('oauth_auth_codes')->whereUserId($user->id)->delete();
|
||||||
ProfileSponsor::whereProfileId($user->profile_id)->delete();
|
ProfileSponsor::whereProfileId($user->profile_id)->delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
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();
|
||||||
|
PublicTimelineService::warmCache(true, 400);
|
||||||
$this->deleteProfile($user);
|
$this->deleteProfile($user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue