(ctx context.Context, rt event.APIClient, out *VCNoteGeneratedOutput)
| 73 | } |
| 74 | |
| 75 | func fillVCNoteGeneratedDetails(ctx context.Context, rt event.APIClient, out *VCNoteGeneratedOutput) { |
| 76 | if rt == nil || out == nil || out.NoteID == "" { |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | path := fmt.Sprintf(pathNoteDetailFmt, validate.EncodePathSegment(out.NoteID)) |
| 81 | |
| 82 | type noteDetailResp struct { |
| 83 | Data struct { |
| 84 | Note struct { |
| 85 | Artifacts []struct { |
| 86 | ArtifactType int `json:"artifact_type"` |
| 87 | DocToken string `json:"doc_token"` |
| 88 | } `json:"artifacts"` |
| 89 | NoteSource struct { |
| 90 | SourceEntityID string `json:"source_entity_id"` |
| 91 | SourceType string `json:"source_type"` |
| 92 | } `json:"note_source"` |
| 93 | } `json:"note"` |
| 94 | } `json:"data"` |
| 95 | } |
| 96 | |
| 97 | for attempt := 0; attempt <= vcNoteDetailMaxRetries; attempt++ { |
| 98 | if attempt > 0 { |
| 99 | time.Sleep(vcNoteDetailRetryDelay) |
| 100 | } |
| 101 | |
| 102 | raw, err := rt.CallAPI(ctx, "GET", path, nil) |
| 103 | if err != nil { |
| 104 | if isLarkCode(err, vcNoteDetailNotFoundCode) { |
| 105 | continue |
| 106 | } |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | var resp noteDetailResp |
| 111 | if err := json.Unmarshal(raw, &resp); err != nil { |
| 112 | continue |
| 113 | } |
| 114 | |
| 115 | var noteToken, verbatimToken string |
| 116 | for _, artifact := range resp.Data.Note.Artifacts { |
| 117 | switch artifact.ArtifactType { |
| 118 | case vcNoteArtifactTypeNote: |
| 119 | if noteToken == "" { |
| 120 | noteToken = artifact.DocToken |
| 121 | } |
| 122 | case vcNoteArtifactTypeVerbatim: |
| 123 | if verbatimToken == "" { |
| 124 | verbatimToken = artifact.DocToken |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | if noteToken == "" && verbatimToken == "" { |
| 130 | continue |
| 131 | } |
| 132 |
no test coverage detected