* Refactoring for Simbrief not working #1005 * Style fixes * Update tests for new briefing URL * Check the OFP user * Comment out user check temporarily
This commit is contained in:
@@ -4,9 +4,11 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Exceptions\AssetNotFound;
|
||||
use App\Exceptions\Unauthorized;
|
||||
use App\Http\Resources\Flight as FlightResource;
|
||||
use App\Http\Resources\Navdata as NavdataResource;
|
||||
use App\Models\SimBrief;
|
||||
use App\Models\User;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\FareService;
|
||||
@@ -152,20 +154,25 @@ class FlightController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function briefing($id)
|
||||
public function briefing(string $id)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$w = [
|
||||
'user_id' => $user->id,
|
||||
'flight_id' => $id,
|
||||
'id' => $id,
|
||||
];
|
||||
|
||||
/** @var SimBrief $simbrief */
|
||||
$simbrief = SimBrief::where($w)->first();
|
||||
|
||||
if ($simbrief === null) {
|
||||
throw new AssetNotFound(new Exception('Flight briefing not found'));
|
||||
}
|
||||
|
||||
/*if ($simbrief->user_id !== $user->id) {
|
||||
throw new Unauthorized(new Exception('User cannot access another user\'s simbrief'));
|
||||
}*/
|
||||
|
||||
return response($simbrief->acars_xml, 200, [
|
||||
'Content-Type' => 'application/xml',
|
||||
]);
|
||||
|
||||
@@ -22,8 +22,6 @@ use App\Models\Acars;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepFieldSource;
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\PirepComment;
|
||||
use App\Repositories\AcarsRepository;
|
||||
@@ -38,9 +36,6 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class PirepController
|
||||
*/
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $acarsRepo;
|
||||
@@ -93,6 +88,10 @@ class PirepController extends Controller
|
||||
$attrs['created_at'] = Carbon::createFromTimeString($attrs['created_at']);
|
||||
}
|
||||
|
||||
if (array_key_exists('submitted_at', $attrs)) {
|
||||
$attrs['submitted_at'] = Carbon::createFromTimeString($attrs['submitted_at']);
|
||||
}
|
||||
|
||||
if (array_key_exists('updated_at', $attrs)) {
|
||||
$attrs['updated_at'] = Carbon::createFromTimeString($attrs['updated_at']);
|
||||
}
|
||||
@@ -306,14 +305,8 @@ class PirepController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$attrs['state'] = PirepState::PENDING;
|
||||
$attrs['status'] = PirepStatus::ARRIVED;
|
||||
$attrs['submitted_at'] = Carbon::now('UTC');
|
||||
|
||||
$pirep = $this->pirepRepo->update($attrs, $pirep_id);
|
||||
|
||||
try {
|
||||
$pirep = $this->pirepSvc->create($pirep);
|
||||
$pirep = $this->pirepSvc->file($pirep, $attrs);
|
||||
$this->updateFields($pirep, $request);
|
||||
$this->updateFares($pirep, $request);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -232,7 +232,7 @@ class SimBriefController
|
||||
$ofp_id = $request->input('ofp_id');
|
||||
$flight_id = $request->input('flight_id');
|
||||
|
||||
$simbrief = $this->simBriefSvc->checkForOfp(Auth::user()->id, $ofp_id, $flight_id);
|
||||
$simbrief = $this->simBriefSvc->downloadOfp(Auth::user()->id, $ofp_id, $flight_id);
|
||||
if ($simbrief === null) {
|
||||
$error = new AssetNotFound(new Exception('Simbrief OFP not found'));
|
||||
return $error->getResponse();
|
||||
|
||||
Reference in New Issue
Block a user