aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/convert/convert.go22
-rw-r--r--routers/repo/webhook.go4
2 files changed, 23 insertions, 3 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go
index 0dc73fcd67..cda1d86b45 100644
--- a/routers/api/v1/convert/convert.go
+++ b/routers/api/v1/convert/convert.go
@@ -69,15 +69,31 @@ func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
}
func ToCommit(c *git.Commit) *api.PayloadCommit {
+ authorUsername := ""
+ author, err := models.GetUserByEmail(c.Author.Email)
+ if err == nil {
+ authorUsername = author.Name
+ }
+ committerUsername := ""
+ committer, err := models.GetUserByEmail(c.Committer.Email)
+ if err == nil {
+ committerUsername = committer.Name
+ }
return &api.PayloadCommit{
ID: c.ID.String(),
Message: c.Message(),
URL: "Not implemented",
Author: &api.PayloadAuthor{
- Name: c.Committer.Name,
- Email: c.Committer.Email,
- /* UserName: c.Committer.UserName, */
+ Name: c.Author.Name,
+ Email: c.Author.Email,
+ UserName: authorUsername,
+ },
+ Committer: &api.PayloadCommitter{
+ Name: c.Committer.Name,
+ Email: c.Committer.Email,
+ UserName: committerUsername,
},
+ Timestamp: c.Author.When,
}
}
diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go
index 715c6a4c72..8b0153e689 100644
--- a/routers/repo/webhook.go
+++ b/routers/repo/webhook.go
@@ -359,6 +359,10 @@ func TestWebhook(ctx *context.Context) {
Name: ctx.Repo.Commit.Author.Name,
Email: ctx.Repo.Commit.Author.Email,
},
+ Committer: &api.PayloadCommitter{
+ Name: ctx.Repo.Commit.Committer.Name,
+ Email: ctx.Repo.Commit.Committer.Email,
+ },
},
},
Repo: ctx.Repo.Repository.ComposePayload(),