|
6 | 6 | use App\Jobs\StatusPipeline\NewStatusPipeline;
|
7 | 7 | use App\Jobs\StatusPipeline\StatusDelete;
|
8 | 8 | use App\Jobs\SharePipeline\SharePipeline;
|
| 9 | +use App\AccountInterstitial; |
9 | 10 | use App\Media;
|
10 | 11 | use App\Profile;
|
11 | 12 | use App\Status;
|
@@ -162,14 +163,49 @@ public function delete(Request $request)
|
162 | 163 |
|
163 | 164 | $status = Status::findOrFail($request->input('item'));
|
164 | 165 |
|
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) { |
166 | 201 | Cache::forget('profile:status_count:'.$status->profile_id);
|
167 | 202 | StatusDelete::dispatch($status);
|
168 | 203 | }
|
| 204 | + |
169 | 205 | if($request->wantsJson()) {
|
170 | 206 | return response()->json(['Status successfully deleted.']);
|
171 | 207 | } else {
|
172 |
| - return redirect(Auth::user()->url()); |
| 208 | + return redirect($user->url()); |
173 | 209 | }
|
174 | 210 | }
|
175 | 211 |
|
|
0 commit comments