Skip to content

Commit 003caf7

Browse files
committed
Update StatusController, add interstitial logic
1 parent 342e7a5 commit 003caf7

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

app/Http/Controllers/StatusController.php

+38-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Jobs\StatusPipeline\NewStatusPipeline;
77
use App\Jobs\StatusPipeline\StatusDelete;
88
use App\Jobs\SharePipeline\SharePipeline;
9+
use App\AccountInterstitial;
910
use App\Media;
1011
use App\Profile;
1112
use App\Status;
@@ -162,14 +163,49 @@ public function delete(Request $request)
162163

163164
$status = Status::findOrFail($request->input('item'));
164165

165-
if ($status->profile_id === Auth::user()->profile->id || Auth::user()->is_admin == true) {
166+
$user = Auth::user();
167+
168+
if($status->profile_id != $user->profile->id &&
169+
$user->is_admin == true &&
170+
$status->uri == null
171+
) {
172+
$media = $status->media;
173+
174+
$ai = new AccountInterstitial;
175+
$ai->user_id = $status->profile->user_id;
176+
$ai->type = 'post.removed';
177+
$ai->view = 'account.moderation.post.removed';
178+
$ai->item_type = 'App\Status';
179+
$ai->item_id = $status->id;
180+
$ai->has_media = (bool) $media->count();
181+
$ai->blurhash = $media->count() ? $media->first()->blurhash : null;
182+
$ai->meta = json_encode([
183+
'caption' => $status->caption,
184+
'created_at' => $status->created_at,
185+
'type' => $status->type,
186+
'url' => $status->url(),
187+
'is_nsfw' => $status->is_nsfw,
188+
'scope' => $status->scope,
189+
'reblog' => $status->reblog_of_id,
190+
'likes_count' => $status->likes_count,
191+
'reblogs_count' => $status->reblogs_count,
192+
]);
193+
$ai->save();
194+
195+
$u = $status->profile->user;
196+
$u->has_interstitial = true;
197+
$u->save();
198+
}
199+
200+
if ($status->profile_id == $user->profile->id || $user->is_admin == true) {
166201
Cache::forget('profile:status_count:'.$status->profile_id);
167202
StatusDelete::dispatch($status);
168203
}
204+
169205
if($request->wantsJson()) {
170206
return response()->json(['Status successfully deleted.']);
171207
} else {
172-
return redirect(Auth::user()->url());
208+
return redirect($user->url());
173209
}
174210
}
175211

0 commit comments

Comments
 (0)