(c *Context, w http.ResponseWriter, r *http.Request)
| 362 | } |
| 363 | |
| 364 | func cancelJob(c *Context, w http.ResponseWriter, r *http.Request) { |
| 365 | c.RequireJobId() |
| 366 | if c.Err != nil { |
| 367 | return |
| 368 | } |
| 369 | |
| 370 | auditRec := c.MakeAuditRecord(model.AuditEventCancelJob, model.AuditStatusFail) |
| 371 | defer c.LogAuditRec(auditRec) |
| 372 | model.AddEventParameterToAuditRec(auditRec, "job_id", c.Params.JobId) |
| 373 | |
| 374 | job, err := c.App.GetJob(c.AppContext, c.Params.JobId) |
| 375 | if err != nil { |
| 376 | c.Err = err |
| 377 | return |
| 378 | } |
| 379 | |
| 380 | auditRec.AddEventPriorState(job) |
| 381 | auditRec.AddEventObjectType("job") |
| 382 | |
| 383 | // if permission to create, permission to cancel, same permission |
| 384 | hasPermission, permissionRequired := c.App.SessionHasPermissionToCreateJob(*c.AppContext.Session(), job) |
| 385 | if permissionRequired == nil { |
| 386 | c.Err = model.NewAppError("unableToCancelJob", "api.job.unable_to_create_job.incorrect_job_type", nil, "", http.StatusBadRequest) |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | if !hasPermission { |
| 391 | c.SetPermissionError(permissionRequired) |
| 392 | return |
| 393 | } |
| 394 | |
| 395 | if err := c.App.CancelJob(c.AppContext, c.Params.JobId); err != nil { |
| 396 | c.Err = err |
| 397 | return |
| 398 | } |
| 399 | |
| 400 | auditRec.Success() |
| 401 | |
| 402 | ReturnStatusOK(w) |
| 403 | } |
| 404 | |
| 405 | func updateJobStatus(c *Context, w http.ResponseWriter, r *http.Request) { |
| 406 | c.RequireJobId() |
nothing calls this directly
no test coverage detected
searching dependent graphs…