mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-19 21:11:26 +00:00
commit
6b1e73ef99
8 changed files with 188 additions and 214 deletions
|
@ -50,6 +50,10 @@ use App\{
|
||||||
UserFilter,
|
UserFilter,
|
||||||
UserSetting,
|
UserSetting,
|
||||||
};
|
};
|
||||||
|
use App\Models\Conversation;
|
||||||
|
use App\Models\Poll;
|
||||||
|
use App\Models\PollVote;
|
||||||
|
use App\Models\Portfolio;
|
||||||
use App\Models\UserPronoun;
|
use App\Models\UserPronoun;
|
||||||
|
|
||||||
class DeleteAccountPipeline implements ShouldQueue
|
class DeleteAccountPipeline implements ShouldQueue
|
||||||
|
@ -59,6 +63,9 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
public $timeout = 900;
|
public $timeout = 900;
|
||||||
|
public $tries = 3;
|
||||||
|
public $maxExceptions = 1;
|
||||||
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
{
|
{
|
||||||
|
@ -68,41 +75,26 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
|
$profile = $user->profile;
|
||||||
|
$id = $user->profile_id;
|
||||||
$this->deleteUserColumns($user);
|
$this->deleteUserColumns($user);
|
||||||
AccountService::del($user->profile_id);
|
AccountService::del($user->profile_id);
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
|
||||||
AccountLog::whereItemType('App\User')->whereItemId($user->id)->forceDelete();
|
AccountLog::whereItemType('App\User')->whereItemId($user->id)->forceDelete();
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
|
||||||
AccountInterstitial::whereUserId($user->id)->delete();
|
AccountInterstitial::whereUserId($user->id)->delete();
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
// Delete Avatar
|
||||||
if($user->profile) {
|
$profile->avatar->forceDelete();
|
||||||
$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'));
|
|
||||||
if($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$disk = Storage::disk(config('filesystems.local'));
|
|
||||||
if($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$avatar->forceDelete();
|
// Delete Poll Votes
|
||||||
}
|
PollVote::whereProfileId($id)->delete();
|
||||||
|
|
||||||
$id = $user->profile_id;
|
// Delete Polls
|
||||||
|
Poll::whereProfileId($id)->delete();
|
||||||
|
|
||||||
|
// Delete Portfolio
|
||||||
|
Portfolio::whereProfileId($id)->delete();
|
||||||
|
|
||||||
ImportData::whereProfileId($id)
|
ImportData::whereProfileId($id)
|
||||||
->cursor()
|
->cursor()
|
||||||
|
@ -113,6 +105,7 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
$data->delete();
|
$data->delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
ImportJob::whereProfileId($id)
|
ImportJob::whereProfileId($id)
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function($data) {
|
->each(function($data) {
|
||||||
|
@ -122,11 +115,13 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
$data->delete();
|
$data->delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
MediaTag::whereProfileId($id)->delete();
|
MediaTag::whereProfileId($id)->delete();
|
||||||
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)->orWhere('to_id', $id)->delete();
|
DirectMessage::whereFromId($id)->orWhere('to_id', $id)->delete();
|
||||||
|
Conversation::whereFromId($id)->orWhere('to_id', $id)->delete();
|
||||||
StatusArchived::whereProfileId($id)->delete();
|
StatusArchived::whereProfileId($id)->delete();
|
||||||
UserPronoun::whereProfileId($id)->delete();
|
UserPronoun::whereProfileId($id)->delete();
|
||||||
FollowRequest::whereFollowingId($id)
|
FollowRequest::whereFollowingId($id)
|
||||||
|
@ -140,13 +135,10 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
});
|
});
|
||||||
FollowerService::delCache($id);
|
FollowerService::delCache($id);
|
||||||
Like::whereProfileId($id)->forceDelete();
|
Like::whereProfileId($id)->forceDelete();
|
||||||
});
|
Mention::whereProfileId($id)->forceDelete();
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
StoryView::whereProfileId($id)->delete();
|
||||||
$pid = $this->user->profile_id;
|
$stories = Story::whereProfileId($id)->get();
|
||||||
|
|
||||||
StoryView::whereProfileId($pid)->delete();
|
|
||||||
$stories = Story::whereProfileId($pid)->get();
|
|
||||||
foreach($stories as $story) {
|
foreach($stories as $story) {
|
||||||
$path = storage_path('app/'.$story->path);
|
$path = storage_path('app/'.$story->path);
|
||||||
if(is_file($path)) {
|
if(is_file($path)) {
|
||||||
|
@ -154,40 +146,17 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
$story->forceDelete();
|
$story->forceDelete();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
UserDevice::whereUserId($user->id)->forceDelete();
|
||||||
$medias = Media::whereUserId($user->id)->get();
|
UserFilter::whereUserId($user->id)->forceDelete();
|
||||||
foreach($medias as $media) {
|
UserSetting::whereUserId($user->id)->forceDelete();
|
||||||
if(config('pixelfed.cloud_storage')) {
|
|
||||||
$disk = Storage::disk(config('filesystems.cloud'));
|
|
||||||
if($disk->exists($media->media_path)) {
|
|
||||||
$disk->delete($media->media_path);
|
|
||||||
}
|
|
||||||
if($disk->exists($media->thumbnail_path)) {
|
|
||||||
$disk->delete($media->thumbnail_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$disk = Storage::disk(config('filesystems.local'));
|
|
||||||
if($disk->exists($media->media_path)) {
|
|
||||||
$disk->delete($media->media_path);
|
|
||||||
}
|
|
||||||
if($disk->exists($media->thumbnail_path)) {
|
|
||||||
$disk->delete($media->thumbnail_path);
|
|
||||||
}
|
|
||||||
$media->forceDelete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
Mention::whereProfileId($id)->forceDelete();
|
||||||
Mention::whereProfileId($user->profile_id)->forceDelete();
|
Notification::whereProfileId($id)
|
||||||
Notification::whereProfileId($user->profile_id)
|
->orWhere('actor_id', $id)
|
||||||
->orWhere('actor_id', $user->profile_id)
|
|
||||||
->forceDelete();
|
->forceDelete();
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
$collections = Collection::whereProfileId($id)->get();
|
||||||
$collections = Collection::whereProfileId($user->profile_id)->get();
|
|
||||||
foreach ($collections as $collection) {
|
foreach ($collections as $collection) {
|
||||||
$collection->items()->delete();
|
$collection->items()->delete();
|
||||||
$collection->delete();
|
$collection->delete();
|
||||||
|
@ -197,31 +166,17 @@ class DeleteAccountPipeline implements ShouldQueue
|
||||||
OauthClient::whereUserId($user->id)->delete();
|
OauthClient::whereUserId($user->id)->delete();
|
||||||
DB::table('oauth_access_tokens')->whereUserId($user->id)->delete();
|
DB::table('oauth_access_tokens')->whereUserId($user->id)->delete();
|
||||||
DB::table('oauth_auth_codes')->whereUserId($user->id)->delete();
|
DB::table('oauth_auth_codes')->whereUserId($user->id)->delete();
|
||||||
ProfileSponsor::whereProfileId($user->profile_id)->delete();
|
ProfileSponsor::whereProfileId($id)->delete();
|
||||||
|
|
||||||
|
Status::whereProfileId($id)->chunk(50, function($statuses) {
|
||||||
|
foreach($statuses as $status) {
|
||||||
|
StatusDelete::dispatch($status)->onQueue('high');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
|
||||||
Status::whereProfileId($user->profile_id)->forceDelete();
|
|
||||||
Report::whereUserId($user->id)->forceDelete();
|
Report::whereUserId($user->id)->forceDelete();
|
||||||
PublicTimelineService::warmCache(true, 400);
|
PublicTimelineService::warmCache(true, 400);
|
||||||
$this->deleteProfile($user);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function deleteProfile($user) {
|
|
||||||
DB::transaction(function() use ($user) {
|
|
||||||
Profile::whereUserId($user->id)->delete();
|
Profile::whereUserId($user->id)->delete();
|
||||||
$this->deleteUserSettings($user);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function deleteUserSettings($user) {
|
|
||||||
|
|
||||||
DB::transaction(function() use ($user) {
|
|
||||||
UserDevice::whereUserId($user->id)->forceDelete();
|
|
||||||
UserFilter::whereUserId($user->id)->forceDelete();
|
|
||||||
UserSetting::whereUserId($user->id)->forceDelete();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function deleteUserColumns($user)
|
protected function deleteUserColumns($user)
|
||||||
|
|
|
@ -39,6 +39,7 @@ use App\{
|
||||||
ReportLog,
|
ReportLog,
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
Status,
|
Status,
|
||||||
|
StatusView,
|
||||||
Story,
|
Story,
|
||||||
StoryView,
|
StoryView,
|
||||||
User,
|
User,
|
||||||
|
@ -46,6 +47,10 @@ use App\{
|
||||||
UserFilter,
|
UserFilter,
|
||||||
UserSetting,
|
UserSetting,
|
||||||
};
|
};
|
||||||
|
use App\Models\Conversation;
|
||||||
|
use App\Models\Poll;
|
||||||
|
use App\Models\PollVote;
|
||||||
|
use App\Services\AccountService;
|
||||||
|
|
||||||
class DeleteRemoteProfilePipeline implements ShouldQueue
|
class DeleteRemoteProfilePipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -53,6 +58,11 @@ class DeleteRemoteProfilePipeline implements ShouldQueue
|
||||||
|
|
||||||
protected $profile;
|
protected $profile;
|
||||||
|
|
||||||
|
public $timeout = 900;
|
||||||
|
public $tries = 3;
|
||||||
|
public $maxExceptions = 1;
|
||||||
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
public function __construct(Profile $profile)
|
public function __construct(Profile $profile)
|
||||||
{
|
{
|
||||||
$this->profile = $profile;
|
$this->profile = $profile;
|
||||||
|
@ -61,30 +71,55 @@ class DeleteRemoteProfilePipeline implements ShouldQueue
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$profile = $this->profile;
|
$profile = $this->profile;
|
||||||
|
$pid = $profile->id;
|
||||||
|
|
||||||
if($profile->domain == null || $profile->private_key) {
|
if($profile->domain == null || $profile->private_key) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::transaction(function() use ($profile) {
|
$profile->status = 'delete';
|
||||||
$profile->avatar->forceDelete();
|
$profile->save();
|
||||||
|
|
||||||
$id = $profile->id;
|
AccountService::del($pid);
|
||||||
|
|
||||||
MediaTag::whereProfileId($id)->delete();
|
// Delete statuses
|
||||||
StatusHashtag::whereProfileId($id)->delete();
|
Status::whereProfileId($pid)
|
||||||
DirectMessage::whereFromId($id)->delete();
|
->chunk(50, function($statuses) {
|
||||||
FollowRequest::whereFollowingId($id)
|
foreach($statuses as $status) {
|
||||||
->orWhere('follower_id', $id)
|
DeleteRemoteStatusPipeline::dispatch($status)->onQueue('delete');
|
||||||
->forceDelete();
|
}
|
||||||
Follower::whereProfileId($id)
|
|
||||||
->orWhere('following_id', $id)
|
|
||||||
->forceDelete();
|
|
||||||
Like::whereProfileId($id)->forceDelete();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function() use ($profile) {
|
// Delete Poll Votes
|
||||||
$pid = $profile->id;
|
PollVote::whereProfileId($pid)->delete();
|
||||||
|
|
||||||
|
// Delete Polls
|
||||||
|
Poll::whereProfileId($pid)->delete();
|
||||||
|
|
||||||
|
// Delete Avatar
|
||||||
|
$profile->avatar->forceDelete();
|
||||||
|
|
||||||
|
// Delete media tags
|
||||||
|
MediaTag::whereProfileId($pid)->delete();
|
||||||
|
|
||||||
|
// Delete DMs
|
||||||
|
DirectMessage::whereFromId($pid)->orWhere('to_id', $pid)->delete();
|
||||||
|
Conversation::whereFromId($pid)->orWhere('to_id', $pid)->delete();
|
||||||
|
|
||||||
|
// Delete FollowRequests
|
||||||
|
FollowRequest::whereFollowingId($pid)
|
||||||
|
->orWhere('follower_id', $pid)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
// Delete relationships
|
||||||
|
Follower::whereProfileId($pid)
|
||||||
|
->orWhere('following_id', $pid)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
// Delete likes
|
||||||
|
Like::whereProfileId($pid)->forceDelete();
|
||||||
|
|
||||||
|
// Delete Story Views + Stories
|
||||||
StoryView::whereProfileId($pid)->delete();
|
StoryView::whereProfileId($pid)->delete();
|
||||||
$stories = Story::whereProfileId($pid)->get();
|
$stories = Story::whereProfileId($pid)->get();
|
||||||
foreach($stories as $story) {
|
foreach($stories as $story) {
|
||||||
|
@ -94,47 +129,27 @@ class DeleteRemoteProfilePipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
$story->forceDelete();
|
$story->forceDelete();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($profile) {
|
// Delete mutes/blocks
|
||||||
$medias = Media::whereProfileId($profile->id)->get();
|
UserFilter::whereFilterableType('App\Profile')->whereFilterableId($pid)->delete();
|
||||||
foreach($medias as $media) {
|
|
||||||
$path = storage_path('app/'.$media->media_path);
|
// Delete mentions
|
||||||
$thumb = storage_path('app/'.$media->thumbnail_path);
|
Mention::whereProfileId($pid)->forceDelete();
|
||||||
if(is_file($path)) {
|
|
||||||
unlink($path);
|
// Delete notifications
|
||||||
}
|
Notification::whereProfileId($pid)
|
||||||
if(is_file($thumb)) {
|
->orWhere('actor_id', $pid)
|
||||||
unlink($thumb);
|
->chunk(50, function($notifications) {
|
||||||
}
|
foreach($notifications as $n) {
|
||||||
$media->forceDelete();
|
$n->forceDelete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function() use ($profile) {
|
// Delete reports
|
||||||
Mention::whereProfileId($profile->id)->forceDelete();
|
Report::whereProfileId($profile->id)->orWhere('reported_profile_id')->forceDelete();
|
||||||
Notification::whereProfileId($profile->id)
|
|
||||||
->orWhere('actor_id', $profile->id)
|
|
||||||
->forceDelete();
|
|
||||||
});
|
|
||||||
|
|
||||||
DB::transaction(function() use ($profile) {
|
// Delete profile
|
||||||
Status::whereProfileId($profile->id)
|
|
||||||
->cursor()
|
|
||||||
->each(function($status) {
|
|
||||||
AccountInterstitial::where('item_type', 'App\Status')
|
|
||||||
->where('item_id', $status->id)
|
|
||||||
->delete();
|
|
||||||
$status->forceDelete();
|
|
||||||
});
|
|
||||||
Report::whereProfileId($profile->id)->forceDelete();
|
|
||||||
$this->deleteProfile($profile);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function deleteProfile($profile) {
|
|
||||||
DB::transaction(function() use ($profile) {
|
|
||||||
Profile::findOrFail($profile->id)->delete();
|
Profile::findOrFail($profile->id)->delete();
|
||||||
});
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,12 @@ use App\Status;
|
||||||
use App\StatusHashtag;
|
use App\StatusHashtag;
|
||||||
use App\StatusView;
|
use App\StatusView;
|
||||||
use App\Notification;
|
use App\Notification;
|
||||||
|
use App\Services\AccountService;
|
||||||
use App\Services\NetworkTimelineService;
|
use App\Services\NetworkTimelineService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
use App\Jobs\ProfilePipeline\DecrementPostCount;
|
use App\Jobs\ProfilePipeline\DecrementPostCount;
|
||||||
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
||||||
|
use Cache;
|
||||||
|
|
||||||
class DeleteRemoteStatusPipeline implements ShouldQueue
|
class DeleteRemoteStatusPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -30,9 +32,10 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
|
||||||
|
|
||||||
protected $status;
|
protected $status;
|
||||||
|
|
||||||
public $timeout = 300;
|
public $timeout = 30;
|
||||||
public $tries = 3;
|
public $tries = 2;
|
||||||
public $maxExceptions = 1;
|
public $maxExceptions = 1;
|
||||||
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
|
@ -41,7 +44,7 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function __construct(Status $status)
|
public function __construct(Status $status)
|
||||||
{
|
{
|
||||||
$this->status = $status->withoutRelations();
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,9 +56,12 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
$status = $this->status;
|
$status = $this->status;
|
||||||
|
|
||||||
|
if(AccountService::get($status->profile_id, true)) {
|
||||||
|
DecrementPostCount::dispatch($status->profile_id)->onQueue('feed');
|
||||||
|
}
|
||||||
|
|
||||||
NetworkTimelineService::del($status->id);
|
NetworkTimelineService::del($status->id);
|
||||||
StatusService::del($status->id, true);
|
Cache::forget(StatusService::key($status->id));
|
||||||
DecrementPostCount::dispatchNow($status->profile_id);
|
|
||||||
Bookmark::whereStatusId($status->id)->delete();
|
Bookmark::whereStatusId($status->id)->delete();
|
||||||
Notification::whereItemType('App\Status')
|
Notification::whereItemType('App\Status')
|
||||||
->whereItemId($status->id)
|
->whereItemId($status->id)
|
||||||
|
@ -73,6 +79,7 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
|
||||||
StatusHashtag::whereStatusId($status->id)->delete();
|
StatusHashtag::whereStatusId($status->id)->delete();
|
||||||
StatusView::whereStatusId($status->id)->delete();
|
StatusView::whereStatusId($status->id)->delete();
|
||||||
Status::whereReblogOfId($status->id)->forceDelete();
|
Status::whereReblogOfId($status->id)->forceDelete();
|
||||||
$status->delete();
|
$status->forceDelete();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ class MediaDeletePipeline implements ShouldQueue
|
||||||
public $timeout = 300;
|
public $timeout = 300;
|
||||||
public $tries = 3;
|
public $tries = 3;
|
||||||
public $maxExceptions = 1;
|
public $maxExceptions = 1;
|
||||||
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
public function __construct(Media $media)
|
public function __construct(Media $media)
|
||||||
{
|
{
|
||||||
|
@ -40,32 +41,27 @@ class MediaDeletePipeline implements ShouldQueue
|
||||||
array_pop($e);
|
array_pop($e);
|
||||||
$i = implode('/', $e);
|
$i = implode('/', $e);
|
||||||
|
|
||||||
if(config_cache('pixelfed.cloud_storage') == true) {
|
if(config('pixelfed.cloud_storage') == true) {
|
||||||
$disk = Storage::disk(config('filesystems.cloud'));
|
$disk = Storage::disk(config('filesystems.cloud'));
|
||||||
|
|
||||||
if($path) {
|
if($path && $disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($thumb) {
|
if($thumb && $disk->exists($thumb)) {
|
||||||
$disk->delete($thumb);
|
$disk->delete($thumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($e) > 4 && count($disk->files($i)) == 0) {
|
|
||||||
$disk->deleteDirectory($i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$disk = Storage::disk(config('filesystems.local'));
|
$disk = Storage::disk(config('filesystems.local'));
|
||||||
|
|
||||||
if($path && $disk->exists($path)) {
|
if($path && $disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($thumb && $disk->exists($thumb)) {
|
if($thumb && $disk->exists($thumb)) {
|
||||||
$disk->delete($thumb);
|
$disk->delete($thumb);
|
||||||
}
|
}
|
||||||
if(count($e) > 4 && count($disk->files($i)) == 0) {
|
|
||||||
$disk->deleteDirectory($i);
|
|
||||||
}
|
|
||||||
|
|
||||||
$media->forceDelete();
|
$media->forceDelete();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class MediaStoragePipeline implements ShouldQueue
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected $media;
|
protected $media;
|
||||||
|
public $deleteWhenMissingModels = true;
|
||||||
|
|
||||||
public function __construct(Media $media)
|
public function __construct(Media $media)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,7 +89,7 @@ class StatusDelete implements ShouldQueue
|
||||||
Media::whereStatusId($status->id)
|
Media::whereStatusId($status->id)
|
||||||
->get()
|
->get()
|
||||||
->each(function($media) {
|
->each(function($media) {
|
||||||
MediaDeletePipeline::dispatchNow($media);
|
MediaDeletePipeline::dispatch($media)->onQueue('mmo');
|
||||||
});
|
});
|
||||||
|
|
||||||
if($status->in_reply_to_id) {
|
if($status->in_reply_to_id) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ class AvatarObserver
|
||||||
@unlink($path);
|
@unlink($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($avatar->cdn_url && config_cache('pixelfed.cloud_storage')) {
|
if(config_cache('pixelfed.cloud_storage')) {
|
||||||
$disk = Storage::disk(config('filesystems.cloud'));
|
$disk = Storage::disk(config('filesystems.cloud'));
|
||||||
$base = Str::startsWith($avatar->media_path, 'cache/avatars/');
|
$base = Str::startsWith($avatar->media_path, 'cache/avatars/');
|
||||||
if($base && $disk->exists($avatar->media_path)) {
|
if($base && $disk->exists($avatar->media_path)) {
|
||||||
|
|
|
@ -274,6 +274,6 @@ class MediaStorageService {
|
||||||
if(!$confirm) {
|
if(!$confirm) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaDeletePipeline::dispatch($media);
|
MediaDeletePipeline::dispatch($media)->onQueue('mmo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue