Update InternalApiController

This commit is contained in:
Daniel Supernault 2018-12-01 23:41:19 -07:00
parent a3ec4a7f4c
commit ed6ebc84f4
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -53,6 +53,7 @@ class InternalApiController extends Controller
$medias = $request->input('media'); $medias = $request->input('media');
$attachments = []; $attachments = [];
$status = new Status; $status = new Status;
$mimes = [];
foreach($medias as $k => $media) { foreach($medias as $k => $media) {
$m = Media::findOrFail($media['id']); $m = Media::findOrFail($media['id']);
@ -69,6 +70,7 @@ class InternalApiController extends Controller
} }
$m->save(); $m->save();
$attachments[] = $m; $attachments[] = $m;
array_push($mimes, $m->mime);
} }
$status->caption = strip_tags($request->caption); $status->caption = strip_tags($request->caption);
@ -84,6 +86,7 @@ class InternalApiController extends Controller
$status->visibility = $visibility; $status->visibility = $visibility;
$status->scope = $visibility; $status->scope = $visibility;
$status->type = StatusController::mimeTypeCheck($mimes);
$status->save(); $status->save();
NewStatusPipeline::dispatch($status); NewStatusPipeline::dispatch($status);
@ -96,6 +99,7 @@ class InternalApiController extends Controller
$this->validate($request, [ $this->validate($request, [
'page' => 'nullable|min:1|max:3', 'page' => 'nullable|min:1|max:3',
]); ]);
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
$timeago = Carbon::now()->subMonths(6); $timeago = Carbon::now()->subMonths(6);
$notifications = Notification::with('actor') $notifications = Notification::with('actor')
@ -148,8 +152,7 @@ class InternalApiController extends Controller
->get(); ->get();
$posts = Status::select('id', 'caption', 'profile_id') $posts = Status::select('id', 'caption', 'profile_id')
->whereNull('in_reply_to_id') ->whereHas('media')
->whereNull('reblog_of_id')
->whereIsNsfw(false) ->whereIsNsfw(false)
->whereVisibility('public') ->whereVisibility('public')
->whereNotIn('profile_id', $following) ->whereNotIn('profile_id', $following)
@ -233,8 +236,7 @@ class InternalApiController extends Controller
$following = array_merge($following, $filters); $following = array_merge($following, $filters);
$posts = Status::select('id', 'caption', 'profile_id') $posts = Status::select('id', 'caption', 'profile_id')
->whereNull('in_reply_to_id') ->whereHas('media')
->whereNull('reblog_of_id')
->whereIsNsfw(false) ->whereIsNsfw(false)
->whereVisibility('public') ->whereVisibility('public')
->whereNotIn('profile_id', $following) ->whereNotIn('profile_id', $following)