diff options
author | Christopher Brickley <brickley@gmail.com> | 2014-09-17 09:11:51 -0400 |
---|---|---|
committer | Christopher Brickley <brickley@gmail.com> | 2014-09-17 09:20:14 -0400 |
commit | f94d7c3f51969d300c3ee1ffdecd642363c207b4 (patch) | |
tree | d0ae8728dd3296f2b85f200fcfe7894be48046fa /models/action.go | |
parent | 061a879cea39a1cce56dcb394b912fad50d7b77a (diff) | |
download | gitea-f94d7c3f51969d300c3ee1ffdecd642363c207b4.tar.gz gitea-f94d7c3f51969d300c3ee1ffdecd642363c207b4.zip |
clarify name/username/owner/pusher for webhook
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/models/action.go b/models/action.go index 295a61ccdb..a6b22b161d 100644 --- a/models/action.go +++ b/models/action.go @@ -243,15 +243,29 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, if !strings.HasPrefix(oldCommitId, "0000000") { compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) } + + pusher_email, pusher_name := "", "" + pusher, err := GetUserByName(userName) + if err == nil { + pusher_email = pusher.Email + pusher_name = pusher.GetFullNameFallback() + } + commits := make([]*PayloadCommit, len(commit.Commits)) for i, cmt := range commit.Commits { + author_username := "" + author, err := GetUserByEmail(cmt.AuthorEmail) + if err == nil { + author_username = author.Name + } commits[i] = &PayloadCommit{ Id: cmt.Sha1, Message: cmt.Message, Url: fmt.Sprintf("%s/commit/%s", repoLink, cmt.Sha1), Author: &PayloadAuthor{ - Name: cmt.AuthorName, - Email: cmt.AuthorEmail, + Name: cmt.AuthorName, + Email: cmt.AuthorEmail, + UserName: author_username, }, } } @@ -266,14 +280,16 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, Website: repo.Website, Watchers: repo.NumWatches, Owner: &PayloadAuthor{ - Name: repoUserName, - Email: actEmail, + Name: repo.Owner.GetFullNameFallback(), + Email: repo.Owner.Email, + UserName: repo.Owner.Name, }, Private: repo.IsPrivate, }, Pusher: &PayloadAuthor{ - Name: repo.Owner.LowerName, - Email: repo.Owner.Email, + Name: pusher_name, + Email: pusher_email, + UserName: userName, }, Before: oldCommitId, After: newCommitId, |