MCPcopy Create free account
hub / github.com/tbphp/gpt-load / RestoreMultipleKeys

Method RestoreMultipleKeys

internal/handler/key_handler.go:298–326  ·  view source on GitHub ↗

RestoreMultipleKeys handles restoring keys from a text block within a specific group.

(c *gin.Context)

Source from the content-addressed store, hash-verified

296
297// RestoreMultipleKeys handles restoring keys from a text block within a specific group.
298func (s *Server) RestoreMultipleKeys(c *gin.Context) {
299 var req KeyTextRequest
300 if err := c.ShouldBindJSON(&req); err != nil {
301 response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error()))
302 return
303 }
304
305 if _, ok := s.findGroupByID(c, req.GroupID); !ok {
306 return
307 }
308
309 if !validateKeysText(c, req.KeysText) {
310 return
311 }
312
313 result, err := s.KeyService.RestoreMultipleKeys(req.GroupID, req.KeysText)
314 if err != nil {
315 if strings.Contains(err.Error(), "batch size exceeds the limit") {
316 response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, err.Error()))
317 } else if err.Error() == "no valid keys found in the input text" {
318 response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, err.Error()))
319 } else {
320 response.Error(c, app_errors.ParseDBError(err))
321 }
322 return
323 }
324
325 response.Success(c, result)
326}
327
328// TestMultipleKeys handles a one-off validation test for multiple keys.
329func (s *Server) TestMultipleKeys(c *gin.Context) {

Callers

nothing calls this directly

Calls 5

findGroupByIDMethod · 0.95
ErrorFunction · 0.92
SuccessFunction · 0.92
validateKeysTextFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected