Update StatusPipeline

This commit is contained in:
Daniel Supernault 2019-05-20 20:39:33 -06:00
parent 03bc9ce466
commit 0ce65865c6
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

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