API: return job from DB instead of authored job

The authored job has tasks & commands in there, which shouldn't be sent
as-is as an API response. Marshalling the task pointers for the
inter-task dependencies would potentially produce quite large responses.
This commit is contained in:
Sybren A. Stüvel 2022-02-14 15:03:17 +01:00
parent f5254c1c65
commit a9790ec579

@ -74,7 +74,12 @@ func (f *Flamenco) SubmitJob(e echo.Context) error {
return sendAPIError(e, http.StatusInternalServerError, "error persisting job in database")
}
return e.JSON(http.StatusOK, authoredJob)
dbJob, err := f.persist.FetchJob(ctx, authoredJob.JobID)
if err != nil {
logger.Error().Err(err).Msg("unable to retrieve just-stored job from database")
return sendAPIError(e, http.StatusInternalServerError, "error retrieving job from database")
}
return e.JSON(http.StatusOK, dbJob)
}
func (f *Flamenco) FetchJob(e echo.Context, jobId string) error {