Update StatusPipeline

pull/1310/head
Daniel Supernault 6 years ago
parent 03bc9ce466
commit 0ce65865c6
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7

@ -2,6 +2,7 @@
namespace App\Jobs\StatusPipeline; namespace App\Jobs\StatusPipeline;
use DB;
use App\{ use App\{
Notification, Notification,
Report, Report,
@ -79,24 +80,32 @@ class StatusDelete implements ShouldQueue
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
$comments = Status::where('in_reply_to_id', $status->id)->get(); if($status->in_reply_to_id) {
foreach ($comments as $comment) { DB::transaction(function() use($status) {
$comment->in_reply_to_id = null; $parent = Status::findOrFail($status->in_reply_to_id);
$comment->save(); --$parent->reply_count;
$parent->save();
});
}
DB::transaction(function() use($status) {
$comments = Status::where('in_reply_to_id', $status->id)->get();
foreach ($comments as $comment) {
$comment->in_reply_to_id = null;
$comment->save();
Notification::whereItemType('App\Status')
->whereItemId($comment->id)
->delete();
}
$status->likes()->delete();
Notification::whereItemType('App\Status') Notification::whereItemType('App\Status')
->whereItemId($comment->id) ->whereItemId($status->id)
->delete(); ->delete();
} StatusHashtag::whereStatusId($status->id)->delete();
Report::whereObjectType('App\Status')
$status->likes()->delete(); ->whereObjectId($status->id)
Notification::whereItemType('App\Status') ->delete();
->whereItemId($status->id) $status->delete();
->delete(); });
StatusHashtag::whereStatusId($status->id)->delete();
Report::whereObjectType('App\Status')
->whereObjectId($status->id)
->delete();
$status->delete();
return true; return true;
} }

Loading…
Cancel
Save