GetTask @Title GetTask @Tag Task API @Description get task @Param id query string true "The id (owner/name) of task" @Success 200 {object} object.Task The Response object @router /get-task [get]
()
| 106 | // @Success 200 {object} object.Task The Response object |
| 107 | // @router /get-task [get] |
| 108 | func (c *ApiController) GetTask() { |
| 109 | id := c.Input().Get("id") |
| 110 | |
| 111 | task, err := object.GetTask(id) |
| 112 | if err != nil { |
| 113 | c.ResponseError(err.Error()) |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | // Check if task exists |
| 118 | if task == nil { |
| 119 | c.ResponseError(c.T("general:The task does not exist")) |
| 120 | return |
| 121 | } |
| 122 | |
| 123 | // Check ownership for non-admins |
| 124 | if !c.IsAdmin() { |
| 125 | username := c.GetSessionUsername() |
| 126 | if task.Owner != username { |
| 127 | c.ResponseError(c.T("auth:Unauthorized operation")) |
| 128 | return |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | c.ResponseOk(task) |
| 133 | } |
| 134 | |
| 135 | // UpdateTask |
| 136 | // @Title UpdateTask |
nothing calls this directly
no test coverage detected