diff options
author | 6543 <6543@obermui.de> | 2021-03-27 17:45:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-27 17:45:26 +0100 |
commit | 290cf75f9343a43d9770b1d6f8f3332a23357e27 (patch) | |
tree | 520f9f8616fbff3b43a1808ef2d73af3f2fe534b /modules | |
parent | f4d27498bdc615605e14f783501e1d1256cd8d22 (diff) | |
download | gitea-290cf75f9343a43d9770b1d6f8f3332a23357e27.tar.gz gitea-290cf75f9343a43d9770b1d6f8f3332a23357e27.zip |
[refactor] Unify the export of user data via API (#15144)
* [refactor] unify how user data is exported via API
* test time via unix timestamp
Diffstat (limited to 'modules')
-rw-r--r-- | modules/convert/git_commit.go | 8 | ||||
-rw-r--r-- | modules/convert/issue.go | 6 | ||||
-rw-r--r-- | modules/convert/issue_comment.go | 2 | ||||
-rw-r--r-- | modules/convert/pull.go | 2 | ||||
-rw-r--r-- | modules/convert/pull_review.go | 13 | ||||
-rw-r--r-- | modules/convert/release.go | 2 | ||||
-rw-r--r-- | modules/convert/repository.go | 2 | ||||
-rw-r--r-- | modules/convert/status.go | 2 | ||||
-rw-r--r-- | modules/convert/user.go | 25 | ||||
-rw-r--r-- | modules/convert/user_test.go | 6 | ||||
-rw-r--r-- | modules/notification/webhook/webhook.go | 80 |
11 files changed, 80 insertions, 68 deletions
diff --git a/modules/convert/git_commit.go b/modules/convert/git_commit.go index 4e30ec2c0b..c647dd4e18 100644 --- a/modules/convert/git_commit.go +++ b/modules/convert/git_commit.go @@ -86,13 +86,13 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string] } if ok { - apiAuthor = ToUser(cacheAuthor, false, false) + apiAuthor = ToUser(cacheAuthor, nil) } else { author, err := models.GetUserByEmail(commit.Author.Email) if err != nil && !models.IsErrUserNotExist(err) { return nil, err } else if err == nil { - apiAuthor = ToUser(author, false, false) + apiAuthor = ToUser(author, nil) if userCache != nil { userCache[commit.Author.Email] = author } @@ -108,13 +108,13 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string] } if ok { - apiCommitter = ToUser(cacheCommitter, false, false) + apiCommitter = ToUser(cacheCommitter, nil) } else { committer, err := models.GetUserByEmail(commit.Committer.Email) if err != nil && !models.IsErrUserNotExist(err) { return nil, err } else if err == nil { - apiCommitter = ToUser(committer, false, false) + apiCommitter = ToUser(committer, nil) if userCache != nil { userCache[commit.Committer.Email] = committer } diff --git a/modules/convert/issue.go b/modules/convert/issue.go index b773e78a6b..da09aeaca4 100644 --- a/modules/convert/issue.go +++ b/modules/convert/issue.go @@ -31,7 +31,7 @@ func ToAPIIssue(issue *models.Issue) *api.Issue { URL: issue.APIURL(), HTMLURL: issue.HTMLURL(), Index: issue.Index, - Poster: ToUser(issue.Poster, false, false), + Poster: ToUser(issue.Poster, nil), Title: issue.Title, Body: issue.Content, Ref: issue.Ref, @@ -66,9 +66,9 @@ func ToAPIIssue(issue *models.Issue) *api.Issue { } if len(issue.Assignees) > 0 { for _, assignee := range issue.Assignees { - apiIssue.Assignees = append(apiIssue.Assignees, ToUser(assignee, false, false)) + apiIssue.Assignees = append(apiIssue.Assignees, ToUser(assignee, nil)) } - apiIssue.Assignee = ToUser(issue.Assignees[0], false, false) // For compatibility, we're keeping the first assignee as `apiIssue.Assignee` + apiIssue.Assignee = ToUser(issue.Assignees[0], nil) // For compatibility, we're keeping the first assignee as `apiIssue.Assignee` } if issue.IsPull { if err := issue.LoadPullRequest(); err != nil { diff --git a/modules/convert/issue_comment.go b/modules/convert/issue_comment.go index cf65c876d3..1610b9f0d8 100644 --- a/modules/convert/issue_comment.go +++ b/modules/convert/issue_comment.go @@ -13,7 +13,7 @@ import ( func ToComment(c *models.Comment) *api.Comment { return &api.Comment{ ID: c.ID, - Poster: ToUser(c.Poster, false, false), + Poster: ToUser(c.Poster, nil), HTMLURL: c.HTMLURL(), IssueURL: c.IssueURL(), PRURL: c.PRURL(), diff --git a/modules/convert/pull.go b/modules/convert/pull.go index 3c24f4532f..8bdf17a049 100644 --- a/modules/convert/pull.go +++ b/modules/convert/pull.go @@ -159,7 +159,7 @@ func ToAPIPullRequest(pr *models.PullRequest) *api.PullRequest { if pr.HasMerged { apiPullRequest.Merged = pr.MergedUnix.AsTimePtr() apiPullRequest.MergedCommitID = &pr.MergedCommitID - apiPullRequest.MergedBy = ToUser(pr.Merger, false, false) + apiPullRequest.MergedBy = ToUser(pr.Merger, nil) } return apiPullRequest diff --git a/modules/convert/pull_review.go b/modules/convert/pull_review.go index 418cb711dc..18c6c8e58c 100644 --- a/modules/convert/pull_review.go +++ b/modules/convert/pull_review.go @@ -20,14 +20,9 @@ func ToPullReview(r *models.Review, doer *models.User) (*api.PullReview, error) r.Reviewer = models.NewGhostUser() } - auth := false - if doer != nil { - auth = doer.IsAdmin || doer.ID == r.ReviewerID - } - result := &api.PullReview{ ID: r.ID, - Reviewer: ToUser(r.Reviewer, doer != nil, auth), + Reviewer: ToUser(r.Reviewer, doer), ReviewerTeam: ToTeam(r.ReviewerTeam), State: api.ReviewStateUnknown, Body: r.Content, @@ -88,14 +83,10 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P for _, lines := range review.CodeComments { for _, comments := range lines { for _, comment := range comments { - auth := false - if doer != nil { - auth = doer.IsAdmin || doer.ID == comment.Poster.ID - } apiComment := &api.PullReviewComment{ ID: comment.ID, Body: comment.Content, - Reviewer: ToUser(comment.Poster, doer != nil, auth), + Reviewer: ToUser(comment.Poster, doer), ReviewID: review.ID, Created: comment.CreatedUnix.AsTime(), Updated: comment.UpdatedUnix.AsTime(), diff --git a/modules/convert/release.go b/modules/convert/release.go index d9def89637..70f0d6e764 100644 --- a/modules/convert/release.go +++ b/modules/convert/release.go @@ -29,7 +29,7 @@ func ToRelease(r *models.Release) *api.Release { IsPrerelease: r.IsPrerelease, CreatedAt: r.CreatedUnix.AsTime(), PublishedAt: r.CreatedUnix.AsTime(), - Publisher: ToUser(r.Publisher, false, false), + Publisher: ToUser(r.Publisher, nil), Attachments: assets, } } diff --git a/modules/convert/repository.go b/modules/convert/repository.go index 63a22bb04e..9a4fbb97ca 100644 --- a/modules/convert/repository.go +++ b/modules/convert/repository.go @@ -102,7 +102,7 @@ func innerToRepo(repo *models.Repository, mode models.AccessMode, isParent bool) return &api.Repository{ ID: repo.ID, - Owner: ToUser(repo.Owner, mode != models.AccessModeNone, mode >= models.AccessModeAdmin), + Owner: ToUserWithAccessMode(repo.Owner, mode), Name: repo.Name, FullName: repo.FullName(), Description: repo.Description, diff --git a/modules/convert/status.go b/modules/convert/status.go index f972fc333c..bb2f964fe4 100644 --- a/modules/convert/status.go +++ b/modules/convert/status.go @@ -24,7 +24,7 @@ func ToCommitStatus(status *models.CommitStatus) *api.CommitStatus { if status.CreatorID != 0 { creator, _ := models.GetUserByID(status.CreatorID) - apiStatus.Creator = ToUser(creator, false, false) + apiStatus.Creator = ToUser(creator, nil) } return apiStatus diff --git a/modules/convert/user.go b/modules/convert/user.go index f5d853fd4d..f3a33aee41 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -11,11 +11,32 @@ import ( ) // ToUser convert models.User to api.User -// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself -func ToUser(user *models.User, signed, authed bool) *api.User { +// if doer is set, private information is added if the doer has the permission to see it +func ToUser(user, doer *models.User) *api.User { + if user == nil { + return nil + } + authed := false + signed := false + if doer != nil { + signed = true + authed = doer.ID == user.ID || doer.IsAdmin + } + return toUser(user, signed, authed) +} + +// ToUserWithAccessMode convert models.User to api.User +// AccessMode is not none show add some more information +func ToUserWithAccessMode(user *models.User, accessMode models.AccessMode) *api.User { if user == nil { return nil } + return toUser(user, accessMode != models.AccessModeNone, false) +} + +// toUser convert models.User to api.User +// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself +func toUser(user *models.User, signed, authed bool) *api.User { result := &api.User{ ID: user.ID, UserName: user.Name, diff --git a/modules/convert/user_test.go b/modules/convert/user_test.go index eff60d5183..3939653441 100644 --- a/modules/convert/user_test.go +++ b/modules/convert/user_test.go @@ -15,14 +15,14 @@ func TestUser_ToUser(t *testing.T) { user1 := models.AssertExistsAndLoadBean(t, &models.User{ID: 1, IsAdmin: true}).(*models.User) - apiUser := ToUser(user1, true, true) + apiUser := toUser(user1, true, true) assert.True(t, apiUser.IsAdmin) user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2, IsAdmin: false}).(*models.User) - apiUser = ToUser(user2, true, true) + apiUser = toUser(user2, true, true) assert.False(t, apiUser.IsAdmin) - apiUser = ToUser(user1, false, false) + apiUser = toUser(user1, false, false) assert.False(t, apiUser.IsAdmin) } diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index a7357a51ca..90dc59021c 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -53,7 +53,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model Index: issue.Index, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } else { err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{ @@ -61,7 +61,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model Index: issue.Index, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } if err != nil { @@ -77,7 +77,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo if err := webhook_services.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{ Forkee: convert.ToRepo(oldRepo, oldMode), Repo: convert.ToRepo(repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }); err != nil { log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err) } @@ -89,8 +89,8 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ Action: api.HookRepoCreated, Repository: convert.ToRepo(repo, models.AccessModeOwner), - Organization: convert.ToUser(u, false, false), - Sender: convert.ToUser(doer, false, false), + Organization: convert.ToUser(u, nil), + Sender: convert.ToUser(doer, nil), }); err != nil { log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err) } @@ -102,8 +102,8 @@ func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.Us if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ Action: api.HookRepoCreated, Repository: convert.ToRepo(repo, models.AccessModeOwner), - Organization: convert.ToUser(u, false, false), - Sender: convert.ToUser(doer, false, false), + Organization: convert.ToUser(u, nil), + Sender: convert.ToUser(doer, nil), }); err != nil { log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err) } @@ -115,8 +115,8 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ Action: api.HookRepoDeleted, Repository: convert.ToRepo(repo, models.AccessModeOwner), - Organization: convert.ToUser(u, false, false), - Sender: convert.ToUser(doer, false, false), + Organization: convert.ToUser(u, nil), + Sender: convert.ToUser(doer, nil), }); err != nil { log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err) } @@ -127,8 +127,8 @@ func (m *webhookNotifier) NotifyMigrateRepository(doer *models.User, u *models.U if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{ Action: api.HookRepoCreated, Repository: convert.ToRepo(repo, models.AccessModeOwner), - Organization: convert.ToUser(u, false, false), - Sender: convert.ToUser(doer, false, false), + Organization: convert.ToUser(u, nil), + Sender: convert.ToUser(doer, nil), }); err != nil { log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err) } @@ -147,7 +147,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo Index: issue.Index, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), } if removed { apiPullRequest.Action = api.HookIssueUnassigned @@ -165,7 +165,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo Index: issue.Index, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), } if removed { apiIssue.Action = api.HookIssueUnassigned @@ -199,7 +199,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model }, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } else { err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ @@ -212,7 +212,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model }, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(issue.Poster, false, false), + Sender: convert.ToUser(issue.Poster, nil), }) } @@ -234,7 +234,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode Index: issue.Index, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), } if isClosed { apiPullRequest.Action = api.HookIssueClosed @@ -247,7 +247,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode Index: issue.Index, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), } if isClosed { apiIssue.Action = api.HookIssueClosed @@ -277,7 +277,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models Index: issue.Index, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(issue.Poster, false, false), + Sender: convert.ToUser(issue.Poster, nil), }); err != nil { log.Error("PrepareWebhooks: %v", err) } @@ -303,7 +303,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mention Index: pull.Issue.Index, PullRequest: convert.ToAPIPullRequest(pull), Repository: convert.ToRepo(pull.Issue.Repo, mode), - Sender: convert.ToUser(pull.Issue.Poster, false, false), + Sender: convert.ToUser(pull.Issue.Poster, nil), }); err != nil { log.Error("PrepareWebhooks: %v", err) } @@ -324,7 +324,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod }, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } else { err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{ @@ -337,7 +337,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod }, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } if err != nil { @@ -374,7 +374,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme }, }, Repository: convert.ToRepo(c.Issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), IsPull: true, }) } else { @@ -388,7 +388,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme }, }, Repository: convert.ToRepo(c.Issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), IsPull: false, }) } @@ -409,7 +409,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode Issue: convert.ToAPIIssue(issue), Comment: convert.ToComment(comment), Repository: convert.ToRepo(repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), IsPull: true, }) } else { @@ -418,7 +418,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode Issue: convert.ToAPIIssue(issue), Comment: convert.ToComment(comment), Repository: convert.ToRepo(repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), IsPull: false, }) } @@ -453,7 +453,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models Issue: convert.ToAPIIssue(comment.Issue), Comment: convert.ToComment(comment), Repository: convert.ToRepo(comment.Issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), IsPull: true, }) } else { @@ -462,7 +462,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models Issue: convert.ToAPIIssue(comment.Issue), Comment: convert.ToComment(comment), Repository: convert.ToRepo(comment.Issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), IsPull: false, }) } @@ -502,7 +502,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode Index: issue.Index, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, models.AccessModeNone), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } else { err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{ @@ -510,7 +510,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode Index: issue.Index, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } if err != nil { @@ -544,7 +544,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m Index: issue.Index, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } else { err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueMilestone, &api.IssuePayload{ @@ -552,7 +552,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m Index: issue.Index, Issue: convert.ToAPIIssue(issue), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) } if err != nil { @@ -561,7 +561,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m } func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { - apiPusher := convert.ToUser(pusher, false, false) + apiPusher := convert.ToUser(pusher, nil) apiCommits, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL()) if err != nil { log.Error("commits.ToAPIPayloadCommits failed: %v", err) @@ -610,7 +610,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod Index: pr.Issue.Index, PullRequest: convert.ToAPIPullRequest(pr), Repository: convert.ToRepo(pr.Issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), Action: api.HookIssueClosed, } @@ -643,7 +643,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User, }, PullRequest: convert.ToAPIPullRequest(issue.PullRequest), Repository: convert.ToRepo(issue.Repo, mode), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }) if err != nil { @@ -682,7 +682,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review Index: review.Issue.Index, PullRequest: convert.ToAPIPullRequest(pr), Repository: convert.ToRepo(review.Issue.Repo, mode), - Sender: convert.ToUser(review.Reviewer, false, false), + Sender: convert.ToUser(review.Reviewer, nil), Review: &api.ReviewPayload{ Type: string(reviewHookType), Content: review.Content, @@ -693,7 +693,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review } func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repository, refType, refFullName string) { - apiPusher := convert.ToUser(pusher, false, false) + apiPusher := convert.ToUser(pusher, nil) apiRepo := convert.ToRepo(repo, models.AccessModeNone) refName := git.RefEndName(refFullName) @@ -737,14 +737,14 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m Index: pr.Issue.Index, PullRequest: convert.ToAPIPullRequest(pr), Repository: convert.ToRepo(pr.Issue.Repo, models.AccessModeNone), - Sender: convert.ToUser(doer, false, false), + Sender: convert.ToUser(doer, nil), }); err != nil { log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) } } func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repository, refType, refFullName string) { - apiPusher := convert.ToUser(pusher, false, false) + apiPusher := convert.ToUser(pusher, nil) apiRepo := convert.ToRepo(repo, models.AccessModeNone) refName := git.RefEndName(refFullName) @@ -770,7 +770,7 @@ func sendReleaseHook(doer *models.User, rel *models.Release, action api.HookRele Action: action, Release: convert.ToRelease(rel), Repository: convert.ToRepo(rel.Repo, mode), - Sender: convert.ToUser(rel.Publisher, false, false), + Sender: convert.ToUser(rel.Publisher, nil), }); err != nil { log.Error("PrepareWebhooks: %v", err) } @@ -789,7 +789,7 @@ func (m *webhookNotifier) NotifyDeleteRelease(doer *models.User, rel *models.Rel } func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { - apiPusher := convert.ToUser(pusher, false, false) + apiPusher := convert.ToUser(pusher, nil) apiCommits, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL()) if err != nil { log.Error("commits.ToAPIPayloadCommits failed: %v", err) |