Notes returns a channel with note events
(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue)
| 44 | |
| 45 | // Notes returns a channel with note events |
| 46 | func Notes(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { |
| 47 | out := make(chan Event) |
| 48 | |
| 49 | go func() { |
| 50 | defer close(out) |
| 51 | |
| 52 | opts := gitlab.ListIssueNotesOptions{ |
| 53 | OrderBy: gitlab.String("created_at"), |
| 54 | Sort: gitlab.String("asc"), |
| 55 | } |
| 56 | |
| 57 | for { |
| 58 | notes, resp, err := client.Notes.ListIssueNotes(issue.ProjectID, issue.IID, &opts, gitlab.WithContext(ctx)) |
| 59 | |
| 60 | if err != nil { |
| 61 | out <- ErrorEvent{Err: err, Time: time.Now()} |
| 62 | } |
| 63 | |
| 64 | for _, note := range notes { |
| 65 | out <- NoteEvent{*note} |
| 66 | } |
| 67 | |
| 68 | if resp.CurrentPage >= resp.TotalPages { |
| 69 | break |
| 70 | } |
| 71 | |
| 72 | opts.Page = resp.NextPage |
| 73 | } |
| 74 | }() |
| 75 | |
| 76 | return out |
| 77 | } |
| 78 | |
| 79 | // LabelEvents returns a channel with label events. |
| 80 | func LabelEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { |