ctx.SetLinkHeader(int(total), limit)
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
ctx.SetLinkHeader(int(total), listOptions.PageSize)
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 {
ctx.NotFound()
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
ctx.Error(http.StatusInternalServerError, "GetIssueByID", err)
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
ctx.InternalServerError(err)
return
}
- ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
+ ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue))
}
func DeleteIssue(ctx *context.APIContext) {
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
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
return
}
- ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target))
+ ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target))
}
// RemoveIssueDependency remove an issue dependency
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
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
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
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 {
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
}
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
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
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
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
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
}
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
}
ctx.SetTotalCountHeader(count)
- ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
+ ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
}
}
}
- ctx.JSON(http.StatusOK, convert.ToIssue(ctx, issue))
+ ctx.JSON(http.StatusOK, convert.ToIssue(ctx, ctx.Doer, issue))
}
// UpdateIssueTitle change issue's title
}
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 {
}
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) {
newNotifyInputFromIssue(issue, webhook_module.HookEventIssues).WithPayload(&api.IssuePayload{
Action: api.HookIssueOpened,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, issue.Poster, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, issue.Poster, nil),
}).Notify(withMethod(ctx, "NewIssue"))
WithPayload(&api.IssuePayload{
Action: api.HookIssueEdited,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
}).
}
apiIssue := &api.IssuePayload{
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
}
WithPayload(&api.IssuePayload{
Action: action,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
}).
payload := &api.IssueCommentPayload{
Action: action,
- Issue: convert.ToAPIIssue(ctx, comment.Issue),
+ Issue: convert.ToAPIIssue(ctx, doer, comment.Issue),
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
api "code.gitea.io/gitea/modules/structs"
)
-func ToIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
- return toIssue(ctx, issue, WebAssetDownloadURL)
+func ToIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) *api.Issue {
+ return toIssue(ctx, doer, issue, WebAssetDownloadURL)
}
// ToAPIIssue converts an Issue to API format
// it assumes some fields assigned with values:
// Required - Poster, Labels,
// Optional - Milestone, Assignee, PullRequest
-func ToAPIIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
- return toIssue(ctx, issue, APIAssetDownloadURL)
+func ToAPIIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) *api.Issue {
+ 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 {
return &api.Issue{}
}
apiIssue := &api.Issue{
ID: issue.ID,
Index: issue.Index,
- Poster: ToUser(ctx, issue.Poster, nil),
+ Poster: ToUser(ctx, issue.Poster, doer),
Title: issue.Title,
Body: issue.Content,
Attachments: toAttachments(issue.Repo, issue.Attachments, getDownloadURL),
}
// 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))
for i := range il {
- result[i] = ToIssue(ctx, il[i])
+ result[i] = ToIssue(ctx, doer, il[i])
}
return result
}
// 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))
for i := range il {
- result[i] = ToAPIIssue(ctx, il[i])
+ result[i] = ToAPIIssue(ctx, doer, il[i])
}
return result
}
// 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{
ID: t.ID,
IssueID: t.IssueID,
Created: t.Created,
}
if t.Issue != nil {
- apiT.Issue = ToAPIIssue(ctx, t.Issue)
+ apiT.Issue = ToAPIIssue(ctx, doer, t.Issue)
}
if t.User != nil {
apiT.UserName = t.User.Name
}
// 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))
for _, t := range tl {
- result = append(result, ToTrackedTime(ctx, t))
+ result = append(result, ToTrackedTime(ctx, doer, t))
}
return result
}
return nil
}
- comment.TrackedTime = ToTrackedTime(ctx, c.Time)
+ comment.TrackedTime = ToTrackedTime(ctx, doer, c.Time)
}
if c.RefIssueID != 0 {
log.Error("GetIssueByID(%d): %v", c.RefIssueID, err)
return nil
}
- comment.RefIssue = ToAPIIssue(ctx, issue)
+ comment.RefIssue = ToAPIIssue(ctx, doer, issue)
}
if c.RefCommentID != 0 {
}
if c.DependentIssue != nil {
- comment.DependentIssue = ToAPIIssue(ctx, c.DependentIssue)
+ comment.DependentIssue = ToAPIIssue(ctx, doer, c.DependentIssue)
}
return comment
return nil
}
- apiIssue := ToAPIIssue(ctx, pr.Issue)
+ apiIssue := ToAPIIssue(ctx, doer, pr.Issue)
if err := pr.LoadBaseRepo(ctx); err != nil {
log.Error("GetRepositoryById[%d]: %v", pr.ID, err)
return nil
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{
Action: api.HookIssueLabelCleared,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
})
permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer)
apiIssue := &api.IssuePayload{
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
}
From: oldTitle,
},
},
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
})
} else {
apiIssue := &api.IssuePayload{
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
CommitID: commitID,
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssues, &api.IssuePayload{
Action: api.HookIssueOpened,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, issue.Poster, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, issue.Poster, nil),
}); err != nil {
From: oldContent,
},
},
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
})
permission, _ := access_model.GetUserRepoPermission(ctx, c.Issue.Repo, doer)
if err := PrepareWebhooks(ctx, EventSource{Repository: c.Issue.Repo}, eventType, &api.IssueCommentPayload{
Action: api.HookIssueCommentEdited,
- Issue: convert.ToAPIIssue(ctx, c.Issue),
+ Issue: convert.ToAPIIssue(ctx, doer, c.Issue),
Comment: convert.ToAPIComment(ctx, c.Issue.Repo, c),
Changes: &api.ChangesPayload{
Body: &api.ChangesFromPayload{
permission, _ := access_model.GetUserRepoPermission(ctx, repo, doer)
if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, eventType, &api.IssueCommentPayload{
Action: api.HookIssueCommentCreated,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Comment: convert.ToAPIComment(ctx, repo, comment),
Repository: convert.ToRepo(ctx, repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
permission, _ := access_model.GetUserRepoPermission(ctx, comment.Issue.Repo, doer)
if err := PrepareWebhooks(ctx, EventSource{Repository: comment.Issue.Repo}, eventType, &api.IssueCommentPayload{
Action: api.HookIssueCommentDeleted,
- Issue: convert.ToAPIIssue(ctx, comment.Issue),
+ Issue: convert.ToAPIIssue(ctx, doer, comment.Issue),
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
})
err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueMilestone, &api.IssuePayload{
Action: hookAction,
Index: issue.Index,
- Issue: convert.ToAPIIssue(ctx, issue),
+ Issue: convert.ToAPIIssue(ctx, doer, issue),
Repository: convert.ToRepo(ctx, issue.Repo, permission),
Sender: convert.ToUser(ctx, doer, nil),
})