MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / importSubscribers

Method importSubscribers

controller/system/import.go:417–454  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

415}
416
417func (i *imlImportConfigController) importSubscribers(ctx context.Context) error {
418
419 applyData, err := unmarshal[subscribe_dto.ExportApproval]("apply")
420 if err != nil {
421 return err
422 }
423 for _, d := range applyData {
424 err = i.catalogueModule.Subscribe(ctx, &catalogue_dto.SubscribeService{
425 Service: d.Service,
426 Applications: []string{
427 d.Application,
428 },
429 Reason: d.Reason,
430 })
431 if err != nil {
432 return fmt.Errorf("application(%s) subscribe service(%s) error: %v", d.Application, d.Service, err)
433 }
434 }
435 data, err := unmarshal[subscribe_dto.ExportSubscriber]("subscribe")
436 if err != nil {
437 return err
438 }
439 for _, d := range data {
440 err = i.subscribeModule.ExistSubscriber(ctx, d.Service, d.Subscriber)
441 if err == nil {
442 continue
443 }
444 err = i.subscribeModule.AddSubscriber(ctx, d.Service, &subscribe_dto.AddSubscriber{
445 Application: d.Subscriber,
446 })
447 if err != nil {
448 return fmt.Errorf("update subscriber(%s) error: %v", d.Id, err)
449 }
450
451 }
452
453 return nil
454}

Callers 1

ImportAllMethod · 0.95

Calls 3

SubscribeMethod · 0.65
ExistSubscriberMethod · 0.65
AddSubscriberMethod · 0.65

Tested by

no test coverage detected