CopyGroup handles copying a group with optional content.
(c *gin.Context)
| 393 | // CopyGroup handles copying a group with optional content. |
| 394 | |
| 395 | func (s *Server) CopyGroup(c *gin.Context) { |
| 396 | id, err := strconv.Atoi(c.Param("id")) |
| 397 | if err != nil { |
| 398 | response.ErrorI18nFromAPIError(c, app_errors.ErrBadRequest, "validation.invalid_group_id") |
| 399 | return |
| 400 | } |
| 401 | |
| 402 | var req GroupCopyRequest |
| 403 | if err := c.ShouldBindJSON(&req); err != nil { |
| 404 | response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error())) |
| 405 | return |
| 406 | } |
| 407 | |
| 408 | newGroup, err := s.GroupService.CopyGroup(c.Request.Context(), uint(id), req.CopyKeys) |
| 409 | if s.handleGroupError(c, err) { |
| 410 | return |
| 411 | } |
| 412 | |
| 413 | groupResponse := s.newGroupResponse(newGroup) |
| 414 | copyResponse := &GroupCopyResponse{ |
| 415 | Group: groupResponse, |
| 416 | } |
| 417 | |
| 418 | response.Success(c, copyResponse) |
| 419 | } |
| 420 | |
| 421 | // List godoc |
| 422 | func (s *Server) List(c *gin.Context) { |
nothing calls this directly
no test coverage detected