Don't give rate limit delay when project is not found

This commit is contained in:
simon987
2019-03-10 09:54:04 -04:00
parent 15a3e66b70
commit d62c70e1be
4 changed files with 40 additions and 5 deletions

View File

@@ -56,6 +56,13 @@ func (api *WebAPI) SubmitTask(r *Request) {
}
reservation := api.ReserveSubmit(createReq.Project)
if reservation == nil {
r.Json(JsonResponse{
Ok: false,
Message: "Project not found",
}, 404)
return
}
delay := reservation.DelayFrom(time.Now()).Seconds()
if delay > 0 {
r.Json(JsonResponse{
@@ -108,6 +115,13 @@ func (api *WebAPI) GetTaskFromProject(r *Request) {
}
reservation := api.ReserveAssign(project)
if reservation == nil {
r.Json(JsonResponse{
Ok: false,
Message: "Project not found",
}, 404)
return
}
delay := reservation.DelayFrom(time.Now()).Seconds()
if delay > 0 {
r.Json(JsonResponse{