ValidateGroupKeys initiates a manual validation task for all keys in a group.
(c *gin.Context)
| 370 | |
| 371 | // ValidateGroupKeys initiates a manual validation task for all keys in a group. |
| 372 | func (s *Server) ValidateGroupKeys(c *gin.Context) { |
| 373 | var req ValidateGroupKeysRequest |
| 374 | if err := c.ShouldBindJSON(&req); err != nil { |
| 375 | response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error())) |
| 376 | return |
| 377 | } |
| 378 | |
| 379 | // Validate status if provided |
| 380 | if req.Status != "" && req.Status != models.KeyStatusActive && req.Status != models.KeyStatusInvalid { |
| 381 | response.ErrorI18nFromAPIError(c, app_errors.ErrValidation, "validation.invalid_status_value") |
| 382 | return |
| 383 | } |
| 384 | |
| 385 | groupDB, ok := s.findGroupByID(c, req.GroupID) |
| 386 | if !ok { |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | group, err := s.GroupManager.GetGroupByName(groupDB.Name) |
| 391 | if err != nil { |
| 392 | response.ErrorI18nFromAPIError(c, app_errors.ErrResourceNotFound, "validation.group_not_found") |
| 393 | return |
| 394 | } |
| 395 | |
| 396 | taskStatus, err := s.KeyManualValidationService.StartValidationTask(group, req.Status) |
| 397 | if err != nil { |
| 398 | response.Error(c, app_errors.NewAPIError(app_errors.ErrTaskInProgress, err.Error())) |
| 399 | return |
| 400 | } |
| 401 | |
| 402 | response.Success(c, taskStatus) |
| 403 | } |
| 404 | |
| 405 | // RestoreAllInvalidKeys sets the status of all 'inactive' keys in a group to 'active'. |
| 406 | func (s *Server) RestoreAllInvalidKeys(c *gin.Context) { |
nothing calls this directly
no test coverage detected