mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Backport #30231 by @lunny Fix #29879 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
52bdeb4d45
commit
e0b9638191
@ -311,7 +311,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||||||
|
|
||||||
ctx.SetLinkHeader(int(total), limit)
|
ctx.SetLinkHeader(int(total), limit)
|
||||||
ctx.SetTotalCountHeader(total)
|
ctx.SetTotalCountHeader(total)
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListIssues list the issues of a repository
|
// ListIssues list the issues of a repository
|
||||||
@ -548,7 +548,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||||||
|
|
||||||
ctx.SetLinkHeader(int(total), listOptions.PageSize)
|
ctx.SetLinkHeader(int(total), listOptions.PageSize)
|
||||||
ctx.SetTotalCountHeader(total)
|
ctx.SetTotalCountHeader(total)
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
|
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
|
||||||
@ -614,7 +614,7 @@ func GetIssue(ctx *context.APIContext) {
|
|||||||
ctx.NotFound()
|
ctx.NotFound()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue))
|
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, ctx.Doer, issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssue create an issue of a repository
|
// CreateIssue create an issue of a repository
|
||||||
@ -737,7 +737,7 @@ func CreateIssue(ctx *context.APIContext) {
|
|||||||
ctx.Error(http.StatusInternalServerError, "GetIssueByID", err)
|
ctx.Error(http.StatusInternalServerError, "GetIssueByID", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
|
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditIssue modify an issue of a repository
|
// EditIssue modify an issue of a repository
|
||||||
@ -911,7 +911,7 @@ func EditIssue(ctx *context.APIContext) {
|
|||||||
ctx.InternalServerError(err)
|
ctx.InternalServerError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
|
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteIssue(ctx *context.APIContext) {
|
func DeleteIssue(ctx *context.APIContext) {
|
||||||
|
@ -107,7 +107,7 @@ func ListIssueAttachments(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue).Attachments)
|
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, ctx.Doer, issue).Attachments)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssueAttachment creates an attachment and saves the given file
|
// CreateIssueAttachment creates an attachment and saves the given file
|
||||||
|
@ -153,7 +153,7 @@ func GetIssueDependencies(ctx *context.APIContext) {
|
|||||||
blockerIssues = append(blockerIssues, &blocker.Issue)
|
blockerIssues = append(blockerIssues, &blocker.Issue)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, blockerIssues))
|
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, blockerIssues))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssueDependency create a new issue dependencies
|
// CreateIssueDependency create a new issue dependencies
|
||||||
@ -214,7 +214,7 @@ func CreateIssueDependency(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target))
|
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveIssueDependency remove an issue dependency
|
// RemoveIssueDependency remove an issue dependency
|
||||||
@ -275,7 +275,7 @@ func RemoveIssueDependency(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target))
|
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIssueBlocks list issues that are blocked by this issue
|
// GetIssueBlocks list issues that are blocked by this issue
|
||||||
@ -381,7 +381,7 @@ func GetIssueBlocks(ctx *context.APIContext) {
|
|||||||
issues = append(issues, &depMeta.Issue)
|
issues = append(issues, &depMeta.Issue)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssueBlocking block the issue given in the body by the issue in path
|
// CreateIssueBlocking block the issue given in the body by the issue in path
|
||||||
@ -438,7 +438,7 @@ func CreateIssueBlocking(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, dependency))
|
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, dependency))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveIssueBlocking unblock the issue given in the body by the issue in path
|
// RemoveIssueBlocking unblock the issue given in the body by the issue in path
|
||||||
@ -495,7 +495,7 @@ func RemoveIssueBlocking(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, dependency))
|
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, dependency))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getParamsIssue(ctx *context.APIContext) *issues_model.Issue {
|
func getParamsIssue(ctx *context.APIContext) *issues_model.Issue {
|
||||||
|
@ -207,7 +207,7 @@ func ListPinnedIssues(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPinnedPullRequests returns a list of all pinned PRs
|
// ListPinnedPullRequests returns a list of all pinned PRs
|
||||||
|
@ -138,7 +138,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetTotalCountHeader(count)
|
ctx.SetTotalCountHeader(count)
|
||||||
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
|
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddTime add time manual to the given issue
|
// AddTime add time manual to the given issue
|
||||||
@ -225,7 +225,7 @@ func AddTime(ctx *context.APIContext) {
|
|||||||
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, trackedTime))
|
ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, user, trackedTime))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetIssueTime reset time manual to the given issue
|
// ResetIssueTime reset time manual to the given issue
|
||||||
@ -455,7 +455,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
|
|||||||
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
|
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListTrackedTimesByRepository lists all tracked times of the repository
|
// ListTrackedTimesByRepository lists all tracked times of the repository
|
||||||
@ -567,7 +567,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetTotalCountHeader(count)
|
ctx.SetTotalCountHeader(count)
|
||||||
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
|
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyTrackedTimes lists all tracked times of the current user
|
// ListMyTrackedTimes lists all tracked times of the current user
|
||||||
@ -629,5 +629,5 @@ func ListMyTrackedTimes(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetTotalCountHeader(count)
|
ctx.SetTotalCountHeader(count)
|
||||||
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
|
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
|
||||||
}
|
}
|
||||||
|
@ -2179,7 +2179,7 @@ func GetIssueInfo(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, convert.ToIssue(ctx, issue))
|
ctx.JSON(http.StatusOK, convert.ToIssue(ctx, ctx.Doer, issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateIssueTitle change issue's title
|
// UpdateIssueTitle change issue's title
|
||||||
@ -2709,7 +2709,7 @@ func SearchIssues(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetTotalCountHeader(total)
|
ctx.SetTotalCountHeader(total)
|
||||||
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, issues))
|
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, ctx.Doer, issues))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
|
func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
|
||||||
@ -2879,7 +2879,7 @@ func ListIssues(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetTotalCountHeader(total)
|
ctx.SetTotalCountHeader(total)
|
||||||
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, issues))
|
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, ctx.Doer, issues))
|
||||||
}
|
}
|
||||||
|
|
||||||
func BatchDeleteIssues(ctx *context.Context) {
|
func BatchDeleteIssues(ctx *context.Context) {
|
||||||
|
@ -49,7 +49,7 @@ func (n *actionsNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu
|
|||||||
newNotifyInputFromIssue(issue, webhook_module.HookEventIssues).WithPayload(&api.IssuePayload{
|
newNotifyInputFromIssue(issue, webhook_module.HookEventIssues).WithPayload(&api.IssuePayload{
|
||||||
Action: api.HookIssueOpened,
|
Action: api.HookIssueOpened,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, issue.Poster, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, issue.Poster, nil),
|
Sender: convert.ToUser(ctx, issue.Poster, nil),
|
||||||
}).Notify(withMethod(ctx, "NewIssue"))
|
}).Notify(withMethod(ctx, "NewIssue"))
|
||||||
@ -89,7 +89,7 @@ func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_mod
|
|||||||
WithPayload(&api.IssuePayload{
|
WithPayload(&api.IssuePayload{
|
||||||
Action: api.HookIssueEdited,
|
Action: api.HookIssueEdited,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
}).
|
}).
|
||||||
@ -127,7 +127,7 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
|
|||||||
}
|
}
|
||||||
apiIssue := &api.IssuePayload{
|
apiIssue := &api.IssuePayload{
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues
|
|||||||
WithPayload(&api.IssuePayload{
|
WithPayload(&api.IssuePayload{
|
||||||
Action: action,
|
Action: action,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
}).
|
}).
|
||||||
@ -293,7 +293,7 @@ func notifyIssueCommentChange(ctx context.Context, doer *user_model.User, commen
|
|||||||
|
|
||||||
payload := &api.IssueCommentPayload{
|
payload := &api.IssueCommentPayload{
|
||||||
Action: action,
|
Action: action,
|
||||||
Issue: convert.ToAPIIssue(ctx, comment.Issue),
|
Issue: convert.ToAPIIssue(ctx, doer, comment.Issue),
|
||||||
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
|
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
|
||||||
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
|
@ -18,19 +18,19 @@ import (
|
|||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
|
func ToIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) *api.Issue {
|
||||||
return toIssue(ctx, issue, WebAssetDownloadURL)
|
return toIssue(ctx, doer, issue, WebAssetDownloadURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToAPIIssue converts an Issue to API format
|
// ToAPIIssue converts an Issue to API format
|
||||||
// it assumes some fields assigned with values:
|
// it assumes some fields assigned with values:
|
||||||
// Required - Poster, Labels,
|
// Required - Poster, Labels,
|
||||||
// Optional - Milestone, Assignee, PullRequest
|
// Optional - Milestone, Assignee, PullRequest
|
||||||
func ToAPIIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
|
func ToAPIIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) *api.Issue {
|
||||||
return toIssue(ctx, issue, APIAssetDownloadURL)
|
return toIssue(ctx, doer, issue, APIAssetDownloadURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func(repo *repo_model.Repository, attach *repo_model.Attachment) string) *api.Issue {
|
func toIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, getDownloadURL func(repo *repo_model.Repository, attach *repo_model.Attachment) string) *api.Issue {
|
||||||
if err := issue.LoadLabels(ctx); err != nil {
|
if err := issue.LoadLabels(ctx); err != nil {
|
||||||
return &api.Issue{}
|
return &api.Issue{}
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func
|
|||||||
apiIssue := &api.Issue{
|
apiIssue := &api.Issue{
|
||||||
ID: issue.ID,
|
ID: issue.ID,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Poster: ToUser(ctx, issue.Poster, nil),
|
Poster: ToUser(ctx, issue.Poster, doer),
|
||||||
Title: issue.Title,
|
Title: issue.Title,
|
||||||
Body: issue.Content,
|
Body: issue.Content,
|
||||||
Attachments: toAttachments(issue.Repo, issue.Attachments, getDownloadURL),
|
Attachments: toAttachments(issue.Repo, issue.Attachments, getDownloadURL),
|
||||||
@ -114,25 +114,25 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ToIssueList converts an IssueList to API format
|
// ToIssueList converts an IssueList to API format
|
||||||
func ToIssueList(ctx context.Context, il issues_model.IssueList) []*api.Issue {
|
func ToIssueList(ctx context.Context, doer *user_model.User, il issues_model.IssueList) []*api.Issue {
|
||||||
result := make([]*api.Issue, len(il))
|
result := make([]*api.Issue, len(il))
|
||||||
for i := range il {
|
for i := range il {
|
||||||
result[i] = ToIssue(ctx, il[i])
|
result[i] = ToIssue(ctx, doer, il[i])
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToAPIIssueList converts an IssueList to API format
|
// ToAPIIssueList converts an IssueList to API format
|
||||||
func ToAPIIssueList(ctx context.Context, il issues_model.IssueList) []*api.Issue {
|
func ToAPIIssueList(ctx context.Context, doer *user_model.User, il issues_model.IssueList) []*api.Issue {
|
||||||
result := make([]*api.Issue, len(il))
|
result := make([]*api.Issue, len(il))
|
||||||
for i := range il {
|
for i := range il {
|
||||||
result[i] = ToAPIIssue(ctx, il[i])
|
result[i] = ToAPIIssue(ctx, doer, il[i])
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToTrackedTime converts TrackedTime to API format
|
// ToTrackedTime converts TrackedTime to API format
|
||||||
func ToTrackedTime(ctx context.Context, t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
|
func ToTrackedTime(ctx context.Context, doer *user_model.User, t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
|
||||||
apiT = &api.TrackedTime{
|
apiT = &api.TrackedTime{
|
||||||
ID: t.ID,
|
ID: t.ID,
|
||||||
IssueID: t.IssueID,
|
IssueID: t.IssueID,
|
||||||
@ -141,7 +141,7 @@ func ToTrackedTime(ctx context.Context, t *issues_model.TrackedTime) (apiT *api.
|
|||||||
Created: t.Created,
|
Created: t.Created,
|
||||||
}
|
}
|
||||||
if t.Issue != nil {
|
if t.Issue != nil {
|
||||||
apiT.Issue = ToAPIIssue(ctx, t.Issue)
|
apiT.Issue = ToAPIIssue(ctx, doer, t.Issue)
|
||||||
}
|
}
|
||||||
if t.User != nil {
|
if t.User != nil {
|
||||||
apiT.UserName = t.User.Name
|
apiT.UserName = t.User.Name
|
||||||
@ -192,10 +192,10 @@ func ToStopWatches(ctx context.Context, sws []*issues_model.Stopwatch) (api.Stop
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ToTrackedTimeList converts TrackedTimeList to API format
|
// ToTrackedTimeList converts TrackedTimeList to API format
|
||||||
func ToTrackedTimeList(ctx context.Context, tl issues_model.TrackedTimeList) api.TrackedTimeList {
|
func ToTrackedTimeList(ctx context.Context, doer *user_model.User, tl issues_model.TrackedTimeList) api.TrackedTimeList {
|
||||||
result := make([]*api.TrackedTime, 0, len(tl))
|
result := make([]*api.TrackedTime, 0, len(tl))
|
||||||
for _, t := range tl {
|
for _, t := range tl {
|
||||||
result = append(result, ToTrackedTime(ctx, t))
|
result = append(result, ToTrackedTime(ctx, doer, t))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
comment.TrackedTime = ToTrackedTime(ctx, c.Time)
|
comment.TrackedTime = ToTrackedTime(ctx, doer, c.Time)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.RefIssueID != 0 {
|
if c.RefIssueID != 0 {
|
||||||
@ -129,7 +129,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
|
|||||||
log.Error("GetIssueByID(%d): %v", c.RefIssueID, err)
|
log.Error("GetIssueByID(%d): %v", c.RefIssueID, err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
comment.RefIssue = ToAPIIssue(ctx, issue)
|
comment.RefIssue = ToAPIIssue(ctx, doer, issue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.RefCommentID != 0 {
|
if c.RefCommentID != 0 {
|
||||||
@ -180,7 +180,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.DependentIssue != nil {
|
if c.DependentIssue != nil {
|
||||||
comment.DependentIssue = ToAPIIssue(ctx, c.DependentIssue)
|
comment.DependentIssue = ToAPIIssue(ctx, doer, c.DependentIssue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return comment
|
return comment
|
||||||
|
@ -33,7 +33,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
apiIssue := ToAPIIssue(ctx, pr.Issue)
|
apiIssue := ToAPIIssue(ctx, doer, pr.Issue)
|
||||||
if err := pr.LoadBaseRepo(ctx); err != nil {
|
if err := pr.LoadBaseRepo(ctx); err != nil {
|
||||||
log.Error("GetRepositoryById[%d]: %v", pr.ID, err)
|
log.Error("GetRepositoryById[%d]: %v", pr.ID, err)
|
||||||
return nil
|
return nil
|
||||||
|
@ -67,7 +67,7 @@ func (m *webhookNotifier) IssueClearLabels(ctx context.Context, doer *user_model
|
|||||||
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{
|
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{
|
||||||
Action: api.HookIssueLabelCleared,
|
Action: api.HookIssueLabelCleared,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
})
|
})
|
||||||
@ -168,7 +168,7 @@ func (m *webhookNotifier) IssueChangeAssignee(ctx context.Context, doer *user_mo
|
|||||||
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer)
|
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer)
|
||||||
apiIssue := &api.IssuePayload{
|
apiIssue := &api.IssuePayload{
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ func (m *webhookNotifier) IssueChangeTitle(ctx context.Context, doer *user_model
|
|||||||
From: oldTitle,
|
From: oldTitle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
})
|
})
|
||||||
@ -250,7 +250,7 @@ func (m *webhookNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
|
|||||||
} else {
|
} else {
|
||||||
apiIssue := &api.IssuePayload{
|
apiIssue := &api.IssuePayload{
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
CommitID: commitID,
|
CommitID: commitID,
|
||||||
@ -281,7 +281,7 @@ func (m *webhookNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu
|
|||||||
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssues, &api.IssuePayload{
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssues, &api.IssuePayload{
|
||||||
Action: api.HookIssueOpened,
|
Action: api.HookIssueOpened,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, issue.Poster, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, issue.Poster, nil),
|
Sender: convert.ToUser(ctx, issue.Poster, nil),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -349,7 +349,7 @@ func (m *webhookNotifier) IssueChangeContent(ctx context.Context, doer *user_mod
|
|||||||
From: oldContent,
|
From: oldContent,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
})
|
})
|
||||||
@ -384,7 +384,7 @@ func (m *webhookNotifier) UpdateComment(ctx context.Context, doer *user_model.Us
|
|||||||
permission, _ := access_model.GetUserRepoPermission(ctx, c.Issue.Repo, doer)
|
permission, _ := access_model.GetUserRepoPermission(ctx, c.Issue.Repo, doer)
|
||||||
if err := PrepareWebhooks(ctx, EventSource{Repository: c.Issue.Repo}, eventType, &api.IssueCommentPayload{
|
if err := PrepareWebhooks(ctx, EventSource{Repository: c.Issue.Repo}, eventType, &api.IssueCommentPayload{
|
||||||
Action: api.HookIssueCommentEdited,
|
Action: api.HookIssueCommentEdited,
|
||||||
Issue: convert.ToAPIIssue(ctx, c.Issue),
|
Issue: convert.ToAPIIssue(ctx, doer, c.Issue),
|
||||||
Comment: convert.ToAPIComment(ctx, c.Issue.Repo, c),
|
Comment: convert.ToAPIComment(ctx, c.Issue.Repo, c),
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
Body: &api.ChangesFromPayload{
|
Body: &api.ChangesFromPayload{
|
||||||
@ -412,7 +412,7 @@ func (m *webhookNotifier) CreateIssueComment(ctx context.Context, doer *user_mod
|
|||||||
permission, _ := access_model.GetUserRepoPermission(ctx, repo, doer)
|
permission, _ := access_model.GetUserRepoPermission(ctx, repo, doer)
|
||||||
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, eventType, &api.IssueCommentPayload{
|
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, eventType, &api.IssueCommentPayload{
|
||||||
Action: api.HookIssueCommentCreated,
|
Action: api.HookIssueCommentCreated,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Comment: convert.ToAPIComment(ctx, repo, comment),
|
Comment: convert.ToAPIComment(ctx, repo, comment),
|
||||||
Repository: convert.ToRepo(ctx, repo, permission),
|
Repository: convert.ToRepo(ctx, repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
@ -449,7 +449,7 @@ func (m *webhookNotifier) DeleteComment(ctx context.Context, doer *user_model.Us
|
|||||||
permission, _ := access_model.GetUserRepoPermission(ctx, comment.Issue.Repo, doer)
|
permission, _ := access_model.GetUserRepoPermission(ctx, comment.Issue.Repo, doer)
|
||||||
if err := PrepareWebhooks(ctx, EventSource{Repository: comment.Issue.Repo}, eventType, &api.IssueCommentPayload{
|
if err := PrepareWebhooks(ctx, EventSource{Repository: comment.Issue.Repo}, eventType, &api.IssueCommentPayload{
|
||||||
Action: api.HookIssueCommentDeleted,
|
Action: api.HookIssueCommentDeleted,
|
||||||
Issue: convert.ToAPIIssue(ctx, comment.Issue),
|
Issue: convert.ToAPIIssue(ctx, doer, comment.Issue),
|
||||||
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
|
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
|
||||||
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
@ -533,7 +533,7 @@ func (m *webhookNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
|
|||||||
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{
|
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{
|
||||||
Action: api.HookIssueLabelUpdated,
|
Action: api.HookIssueLabelUpdated,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
})
|
})
|
||||||
@ -575,7 +575,7 @@ func (m *webhookNotifier) IssueChangeMilestone(ctx context.Context, doer *user_m
|
|||||||
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueMilestone, &api.IssuePayload{
|
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueMilestone, &api.IssuePayload{
|
||||||
Action: hookAction,
|
Action: hookAction,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: convert.ToAPIIssue(ctx, issue),
|
Issue: convert.ToAPIIssue(ctx, doer, issue),
|
||||||
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
Repository: convert.ToRepo(ctx, issue.Repo, permission),
|
||||||
Sender: convert.ToUser(ctx, doer, nil),
|
Sender: convert.ToUser(ctx, doer, nil),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user