DeleteMultipleKeys handles deleting keys from a text block within a specific group.
(c *gin.Context)
| 239 | |
| 240 | // DeleteMultipleKeys handles deleting keys from a text block within a specific group. |
| 241 | func (s *Server) DeleteMultipleKeys(c *gin.Context) { |
| 242 | var req KeyTextRequest |
| 243 | if err := c.ShouldBindJSON(&req); err != nil { |
| 244 | response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error())) |
| 245 | return |
| 246 | } |
| 247 | |
| 248 | if _, ok := s.findGroupByID(c, req.GroupID); !ok { |
| 249 | return |
| 250 | } |
| 251 | |
| 252 | if !validateKeysText(c, req.KeysText) { |
| 253 | return |
| 254 | } |
| 255 | |
| 256 | result, err := s.KeyService.DeleteMultipleKeys(req.GroupID, req.KeysText) |
| 257 | if err != nil { |
| 258 | if strings.Contains(err.Error(), "batch size exceeds the limit") { |
| 259 | response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, err.Error())) |
| 260 | } else if err.Error() == "no valid keys found in the input text" { |
| 261 | response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, err.Error())) |
| 262 | } else { |
| 263 | response.Error(c, app_errors.ParseDBError(err)) |
| 264 | } |
| 265 | return |
| 266 | } |
| 267 | |
| 268 | response.Success(c, result) |
| 269 | } |
| 270 | |
| 271 | // DeleteMultipleKeysAsync handles deleting keys from a text block within a specific group using async task. |
| 272 | func (s *Server) DeleteMultipleKeysAsync(c *gin.Context) { |
nothing calls this directly
no test coverage detected