Skip to content

Commit

Permalink
Add Assignees, Reviewers and ReviewersTeams (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
monrad authored Nov 12, 2024
1 parent 0e84be6 commit 67f0927
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 9 additions & 3 deletions internal/gh/enrichments.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import (
)

type ThreadExtra struct {
User notifications.User `json:"user"`
State string `json:"state"`
HtmlUrl string `json:"html_url"`
User notifications.User `json:"user"`
State string `json:"state"`
HtmlUrl string `json:"html_url"`
Assignees []notifications.User `json:"assignees"`
Reviewers []notifications.User `json:"requested_reviewers"`
ReviewersTeams []notifications.Team `json:"requested_teams"`
}

func (c *Client) Enrich(n *notifications.Notification) error {
Expand All @@ -27,6 +30,9 @@ func (c *Client) Enrich(n *notifications.Notification) error {
n.Author = threadExtra.User
n.Subject.State = threadExtra.State
n.Subject.HtmlUrl = threadExtra.HtmlUrl
n.Assignees = threadExtra.Assignees
n.Reviewers = threadExtra.Reviewers
n.ReviewersTeams = threadExtra.ReviewersTeams

LastCommentor, err := c.getLastCommentor(n)
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions internal/notifications/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ type Notification struct {
Subject Subject `json:"subject"`

// Enriched API fields
Author User `json:"author"`
LatestCommentor User `json:"latest_commentor"`
Author User `json:"author"`
LatestCommentor User `json:"latest_commentor"`
Assignees []User `json:"assignees"`
Reviewers []User `json:"requested_reviewers"`
ReviewersTeams []Team `json:"requested_teams"`

// gh-not specific fields
// Those fields are not part of the GitHub API and will persist between
Expand Down Expand Up @@ -82,6 +85,11 @@ type User struct {
Type string `json:"type"`
}

type Team struct {
Name string `json:"name"`
Id uint `json:"id"`
}

func (n Notifications) Equal(others Notifications) bool {
if len(n) != len(others) {
return false
Expand Down

0 comments on commit 67f0927

Please sign in to comment.