浏览代码

Update delete handler

Daniel Supernault 4 年之前
父节点
当前提交
63eceb8236
共有 2 个文件被更改,包括 38 次插入4 次删除
  1. 32 3
      app/Jobs/DeletePipeline/DeleteAccountPipeline.php
  2. 6 1
      app/Jobs/StatusPipeline/StatusDelete.php

+ 32 - 3
app/Jobs/DeletePipeline/DeleteAccountPipeline.php

@@ -24,8 +24,11 @@ use App\{
 	FollowRequest,
 	FollowRequest,
 	Hashtag,
 	Hashtag,
 	HashtagFollow,
 	HashtagFollow,
+	ImportData,
+	ImportJob,
 	Like,
 	Like,
 	Media,
 	Media,
+	MediaTag,
 	Mention,
 	Mention,
 	Notification,
 	Notification,
 	OauthClient,
 	OauthClient,
@@ -81,10 +84,29 @@ class DeleteAccountPipeline implements ShouldQueue
 
 
 			$id = $user->profile_id;
 			$id = $user->profile_id;
 
 
-			Bookmark::whereProfileId($user->profile_id)->forceDelete();
+			ImportData::whereProfileId($id)
+				->cursor()
+				->each(function($data) {
+					$path = storage_path('app/'.$data->path);
+					if(is_file($path)) {
+						unlink($path);
+					}
+					$data->delete();
+			});
+			ImportJob::whereProfileId($id)
+				->cursor()
+				->each(function($data) {
+					$path = storage_path('app/'.$data->media_json);
+					if(is_file($path)) {
+						unlink($path);
+					}
+					$data->delete();
+			});
+			MediaTag::whereProfileId($id)->delete();
+			Bookmark::whereProfileId($id)->forceDelete();
 			EmailVerification::whereUserId($user->id)->forceDelete();
 			EmailVerification::whereUserId($user->id)->forceDelete();
 			StatusHashtag::whereProfileId($id)->delete();
 			StatusHashtag::whereProfileId($id)->delete();
-			DirectMessage::whereFromId($user->profile_id)->delete();
+			DirectMessage::whereFromId($id)->delete();
 			FollowRequest::whereFollowingId($id)
 			FollowRequest::whereFollowingId($id)
 				->orWhere('follower_id', $id)
 				->orWhere('follower_id', $id)
 				->forceDelete();
 				->forceDelete();
@@ -143,7 +165,14 @@ class DeleteAccountPipeline implements ShouldQueue
 		});
 		});
 
 
 		DB::transaction(function() use ($user) {
 		DB::transaction(function() use ($user) {
-			Status::whereProfileId($user->profile_id)->forceDelete();
+			Status::whereProfileId($user->profile_id)
+				->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);
 		});
 		});

+ 6 - 1
app/Jobs/StatusPipeline/StatusDelete.php

@@ -4,6 +4,7 @@ namespace App\Jobs\StatusPipeline;
 
 
 use DB;
 use DB;
 use App\{
 use App\{
+    AccountInterstitial,
     MediaTag,
     MediaTag,
     Notification,
     Notification,
     Report,
     Report,
@@ -113,7 +114,11 @@ class StatusDelete implements ShouldQueue
                         ->where('item_id', $tag->id)
                         ->where('item_id', $tag->id)
                         ->forceDelete();
                         ->forceDelete();
                     $tag->delete();
                     $tag->delete();
-                });
+            });
+
+            AccountInterstitial::where('item_type', 'App\Status')
+                ->where('item_id', $status->id)
+                ->delete();
 
 
             $status->forceDelete();
             $status->forceDelete();
         });
         });