Update BaseApiController

This commit is contained in:
Daniel Supernault 2019-08-05 21:02:39 -06:00
parent c15cbe3fbb
commit 295ee0d8f7
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -118,7 +118,7 @@ class BaseApiController extends Controller
$since_id = $request->since_id ?? false; $since_id = $request->since_id ?? false;
$only_media = $request->only_media ?? false; $only_media = $request->only_media ?? false;
$user = Auth::user(); $user = Auth::user();
$account = Profile::findOrFail($id); $account = Profile::whereNull('status')->findOrFail($id);
$statuses = $account->statuses()->getQuery(); $statuses = $account->statuses()->getQuery();
if($only_media == true) { if($only_media == true) {
$statuses = $statuses $statuses = $statuses
@ -150,15 +150,6 @@ class BaseApiController extends Controller
return response()->json($res); return response()->json($res);
} }
public function followSuggestions(Request $request)
{
$followers = Auth::user()->profile->recommendFollowers();
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray();
return response()->json($res);
}
public function avatarUpdate(Request $request) public function avatarUpdate(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
@ -197,14 +188,9 @@ class BaseApiController extends Controller
public function showTempMedia(Request $request, int $profileId, $mediaId) public function showTempMedia(Request $request, int $profileId, $mediaId)
{ {
if (!$request->hasValidSignature()) { abort_if(!$request->hasValidSignature(), 404);
abort(401); abort_if(Auth::user()->profile_id !== $profileId, 404);
} $media = Media::whereProfileId(Auth::user()->profile_id)->findOrFail($mediaId);
$profile = Auth::user()->profile;
if($profile->id !== $profileId) {
abort(403);
}
$media = Media::whereProfileId($profile->id)->findOrFail($mediaId);
$path = storage_path('app/'.$media->media_path); $path = storage_path('app/'.$media->media_path);
return response()->file($path); return response()->file($path);
} }