Skip to content
Permalink
Browse files

event, fs, githubapi: add body for issue/change open events

For these event types, having just the title is insufficient
for getting a good idea of what the new issue/change is about.
Start tracking the description body as well.

Updates shurcooL/home#26.
  • Loading branch information...
dmitshur committed Jul 5, 2019
1 parent 8ae19e0 commit 5bd1f2ebf5cd27151012ea3c2f199409a72f292a
Showing with 12 additions and 2 deletions.
  1. +2 −0 event/event.go
  2. +2 −0 fs/schema.go
  3. +8 −2 githubapi/githubapi.go
@@ -184,13 +184,15 @@ func (e *Event) UnmarshalJSON(b []byte) error {
type Issue struct {
Action string // "opened", "closed", "reopened".
IssueTitle string
IssueBody string // Only set when action is "opened".
IssueHTMLURL string
}

// Change is a change event.
type Change struct {
Action string // "opened", "closed", "merged", "reopened".
ChangeTitle string
ChangeBody string // Only set when action is "opened".
ChangeHTMLURL string
}

@@ -246,6 +246,7 @@ func (e eventDisk) Event(actor users.User) event.Event {
type issue struct {
Action string
IssueTitle string
IssueBody string `json:",omitempty"`
IssueHTMLURL string
}

@@ -261,6 +262,7 @@ func (i issue) Issue() event.Issue {
type change struct {
Action string
ChangeTitle string
ChangeBody string `json:",omitempty"`
ChangeHTMLURL string
}

@@ -364,8 +364,11 @@ func convert(
}
switch p := payload.(type) {
case *githubv3.IssuesEvent:
var body string
switch *p.Action {
case "opened", "closed", "reopened":
case "opened":
body = *p.Issue.Body
case "closed", "reopened":

//default:
//log.Println("convert: unsupported *githubv3.IssuesEvent action:", *p.Action)
@@ -375,13 +378,15 @@ func convert(
ee.Payload = event.Issue{
Action: *p.Action,
IssueTitle: title,
IssueBody: body,
IssueHTMLURL: router.IssueURL(ctx, owner, repo, uint64(*p.Issue.Number)),
}
case *githubv3.PullRequestEvent:
var action string
var action, body string
switch {
case *p.Action == "opened":
action = "opened"
body = *p.PullRequest.Body
case *p.Action == "closed" && !*p.PullRequest.Merged:
action = "closed"
case *p.Action == "closed" && *p.PullRequest.Merged:
@@ -397,6 +402,7 @@ func convert(
ee.Payload = event.Change{
Action: action,
ChangeTitle: title,
ChangeBody: body,
ChangeHTMLURL: router.PullRequestURL(ctx, owner, repo, uint64(*p.PullRequest.Number)),
}

0 comments on commit 5bd1f2e

Please sign in to comment.
You can’t perform that action at this time.