StartImportTask initiates a new asynchronous key import task.
(group *models.Group, keysText string)
| 29 | |
| 30 | // StartImportTask initiates a new asynchronous key import task. |
| 31 | func (s *KeyImportService) StartImportTask(group *models.Group, keysText string) (*TaskStatus, error) { |
| 32 | keys := s.KeyService.ParseKeysFromText(keysText) |
| 33 | if len(keys) == 0 { |
| 34 | return nil, fmt.Errorf("no valid keys found in the input text") |
| 35 | } |
| 36 | |
| 37 | initialStatus, err := s.TaskService.StartTask(TaskTypeKeyImport, group.Name, len(keys)) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | |
| 42 | go s.runImport(group, keys) |
| 43 | |
| 44 | return initialStatus, nil |
| 45 | } |
| 46 | |
| 47 | func (s *KeyImportService) runImport(group *models.Group, keys []string) { |
| 48 | progressCallback := func(processed int) { |
no test coverage detected