dmitri.shuralyov.com/service/change/...

Add support for review requested event.
dmitshur committed 2 years ago commit 3120794049bbfedf9cddd3c90f75743fe466a617
githubapi/githubapi.go
@@ -444,10 +444,20 @@ func (s service) ListEvents(ctx context.Context, rs string, id uint64, opt *chan
 							Label struct {
 								Name  string
 								Color string
 							}
 						} `graphql:"...on UnlabeledEvent"`
+						// TODO: Wait for GitHub to add support.
+						//CommentDeletedEvent struct {
+						//	event
+						//} `graphql:"...on CommentDeletedEvent"`
+						ReviewRequestedEvent struct {
+							event
+							RequestedReviewer struct {
+								githubqlActor `graphql:"...on Actor"`
+							}
+						} `graphql:"...on ReviewRequestedEvent"`
 					}
 				} `graphql:"timeline(first:100)"` // TODO: Paginate?
 			} `graphql:"pullRequest(number:$prNumber)"`
 		} `graphql:"repository(owner:$repositoryOwner,name:$repositoryName)"`
 	}
@@ -460,19 +470,15 @@ func (s service) ListEvents(ctx context.Context, rs string, id uint64, opt *chan
 	if err != nil {
 		return nil, err
 	}
 	var events []issues.Event
 	for _, event := range q.Repository.PullRequest.Timeline.Nodes {
-		et := ghEventType(event.Typename)
-		if !et.Valid() {
-			continue
-		}
 		e := issues.Event{
 			//ID:   0, // TODO.
-			Type: et,
+			Type: ghEventType(event.Typename),
 		}
-		switch et {
+		switch e.Type {
 		case issues.Closed:
 			e.Actor = ghActor(event.ClosedEvent.Actor)
 			e.CreatedAt = event.ClosedEvent.CreatedAt.Time
 		case issues.Reopened:
 			e.Actor = ghActor(event.ReopenedEvent.Actor)
@@ -496,10 +502,19 @@ func (s service) ListEvents(ctx context.Context, rs string, id uint64, opt *chan
 			e.CreatedAt = event.UnlabeledEvent.CreatedAt.Time
 			e.Label = &issues.Label{
 				Name:  event.UnlabeledEvent.Label.Name,
 				Color: ghColor(event.UnlabeledEvent.Label.Color),
 			}
+		// TODO: Wait for GitHub to add support.
+		//case issues.CommentDeleted:
+		//	e.Actor = ghActor(event.CommentDeletedEvent.Actor)
+		//	e.CreatedAt = event.CommentDeletedEvent.CreatedAt.Time
+		case "ReviewRequestedEvent":
+			e.Actor = ghActor(event.ReviewRequestedEvent.Actor)
+			e.CreatedAt = event.ReviewRequestedEvent.CreatedAt.Time
+			// TODO: Move RequestedReviewer field to changes-only events (it doesn't apply to issues).
+			e.RequestedReviewer = ghActor(event.ReviewRequestedEvent.RequestedReviewer.githubqlActor)
 		default:
 			continue
 		}
 		events = append(events, e)
 	}
@@ -605,11 +620,11 @@ func ghEventType(typename string) issues.EventType {
 		return issues.Renamed
 	case "LabeledEvent":
 		return issues.Labeled
 	case "UnlabeledEvent":
 		return issues.Unlabeled
-	case "???": // TODO: Wait for GitHub to add support.
+	case "CommentDeletedEvent":
 		return issues.CommentDeleted
 	default:
 		return issues.EventType(typename)
 	}
 }