Complete //todo's

This commit is contained in:
simon987 2019-02-25 18:45:46 -05:00
parent 3415f95337
commit df7f91a475
5 changed files with 9 additions and 5 deletions

View File

@ -158,7 +158,13 @@ func (api *WebAPI) GetManagerList(r *Request) {
func (api *WebAPI) GetManagerListWithRoleOn(r *Request) { func (api *WebAPI) GetManagerListWithRoleOn(r *Request) {
pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64) pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64)
handleErr(err, r) //todo handle invalid id if err != nil || pid <= 0 {
r.Json(JsonResponse{
Ok: false,
Message: "Invalid project id",
}, 400)
return
}
sess := api.Session.StartFasthttp(r.Ctx) sess := api.Session.StartFasthttp(r.Ctx)
manager := sess.Get("manager") manager := sess.Get("manager")

View File

@ -27,13 +27,14 @@ func (r *Request) Json(object JsonResponse, code int) {
logrus.WithError(err).WithFields(logrus.Fields{ logrus.WithError(err).WithFields(logrus.Fields{
"code": code, "code": code,
}).Error("Error during json encoding of object") }).Error("Error during json encoding of object")
return
} }
r.Ctx.Response.SetStatusCode(code) r.Ctx.Response.SetStatusCode(code)
r.Ctx.Response.Header.Set("Content-Type", "application/json") r.Ctx.Response.Header.Set("Content-Type", "application/json")
_, err = r.Ctx.Write(resp) _, err = r.Ctx.Write(resp)
if err != nil { if err != nil {
panic(err) //todo handle differently panic(err)
} }
} }

View File

@ -525,7 +525,6 @@ func (api *WebAPI) SetManagerRoleOnProject(r *Request) {
func (api *WebAPI) SetSecret(r *Request) { func (api *WebAPI) SetSecret(r *Request) {
pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64) pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64)
handleErr(err, r) //todo handle invalid id
if err != nil || pid <= 0 { if err != nil || pid <= 0 {
r.Json(JsonResponse{ r.Json(JsonResponse{
Ok: false, Ok: false,

View File

@ -66,7 +66,6 @@ func (api *WebAPI) SubmitTask(r *Request) {
} }
if createReq.UniqueString != "" { if createReq.UniqueString != "" {
//TODO: Load key from config
createReq.Hash64 = int64(siphash.Hash(1, 2, []byte(createReq.UniqueString))) createReq.Hash64 = int64(siphash.Hash(1, 2, []byte(createReq.UniqueString)))
} }

View File

@ -39,7 +39,6 @@ func (database *Database) SaveTask(task *Task, project int64, hash64 int64, wid
db := database.getDB() db := database.getDB()
//TODO: For some reason it refuses to insert the 64-bit value unless I do that...
res, err := db.Exec(fmt.Sprintf(` res, err := db.Exec(fmt.Sprintf(`
INSERT INTO task (project, max_retries, recipe, priority, max_assign_time, hash64,verification_count) INSERT INTO task (project, max_retries, recipe, priority, max_assign_time, hash64,verification_count)
SELECT $1,$2,$3,$4,$5,NULLIF(%d, 0),$6 FROM worker_access SELECT $1,$2,$3,$4,$5,NULLIF(%d, 0),$6 FROM worker_access