Skip to content

Commit 908426a

Browse files
lunnyGiteaBot
andauthored
Fix missed doer (#30231)
Fix #29879 Co-authored-by: Giteabot <[email protected]>
1 parent ff7aab4 commit 908426a

File tree

11 files changed

+55
-55
lines changed

11 files changed

+55
-55
lines changed

routers/api/v1/repo/issue.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func SearchIssues(ctx *context.APIContext) {
311311

312312
ctx.SetLinkHeader(int(total), limit)
313313
ctx.SetTotalCountHeader(total)
314-
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
314+
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
315315
}
316316

317317
// ListIssues list the issues of a repository
@@ -548,7 +548,7 @@ func ListIssues(ctx *context.APIContext) {
548548

549549
ctx.SetLinkHeader(int(total), listOptions.PageSize)
550550
ctx.SetTotalCountHeader(total)
551-
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
551+
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
552552
}
553553

554554
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
@@ -614,7 +614,7 @@ func GetIssue(ctx *context.APIContext) {
614614
ctx.NotFound()
615615
return
616616
}
617-
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue))
617+
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, ctx.Doer, issue))
618618
}
619619

620620
// CreateIssue create an issue of a repository
@@ -737,7 +737,7 @@ func CreateIssue(ctx *context.APIContext) {
737737
ctx.Error(http.StatusInternalServerError, "GetIssueByID", err)
738738
return
739739
}
740-
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
740+
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue))
741741
}
742742

743743
// EditIssue modify an issue of a repository
@@ -911,7 +911,7 @@ func EditIssue(ctx *context.APIContext) {
911911
ctx.InternalServerError(err)
912912
return
913913
}
914-
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
914+
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue))
915915
}
916916

917917
func DeleteIssue(ctx *context.APIContext) {

routers/api/v1/repo/issue_attachment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func ListIssueAttachments(ctx *context.APIContext) {
107107
return
108108
}
109109

110-
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue).Attachments)
110+
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, ctx.Doer, issue).Attachments)
111111
}
112112

113113
// CreateIssueAttachment creates an attachment and saves the given file

routers/api/v1/repo/issue_dependency.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func GetIssueDependencies(ctx *context.APIContext) {
153153
blockerIssues = append(blockerIssues, &blocker.Issue)
154154
}
155155

156-
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, blockerIssues))
156+
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, blockerIssues))
157157
}
158158

159159
// CreateIssueDependency create a new issue dependencies
@@ -214,7 +214,7 @@ func CreateIssueDependency(ctx *context.APIContext) {
214214
return
215215
}
216216

217-
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target))
217+
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target))
218218
}
219219

220220
// RemoveIssueDependency remove an issue dependency
@@ -275,7 +275,7 @@ func RemoveIssueDependency(ctx *context.APIContext) {
275275
return
276276
}
277277

278-
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target))
278+
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target))
279279
}
280280

281281
// GetIssueBlocks list issues that are blocked by this issue
@@ -381,7 +381,7 @@ func GetIssueBlocks(ctx *context.APIContext) {
381381
issues = append(issues, &depMeta.Issue)
382382
}
383383

384-
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
384+
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
385385
}
386386

387387
// CreateIssueBlocking block the issue given in the body by the issue in path
@@ -438,7 +438,7 @@ func CreateIssueBlocking(ctx *context.APIContext) {
438438
return
439439
}
440440

441-
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, dependency))
441+
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, dependency))
442442
}
443443

444444
// RemoveIssueBlocking unblock the issue given in the body by the issue in path
@@ -495,7 +495,7 @@ func RemoveIssueBlocking(ctx *context.APIContext) {
495495
return
496496
}
497497

498-
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, dependency))
498+
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, dependency))
499499
}
500500

501501
func getParamsIssue(ctx *context.APIContext) *issues_model.Issue {

routers/api/v1/repo/issue_pin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func ListPinnedIssues(ctx *context.APIContext) {
207207
return
208208
}
209209

210-
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
210+
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues))
211211
}
212212

213213
// ListPinnedPullRequests returns a list of all pinned PRs

routers/api/v1/repo/issue_tracked_time.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
138138
}
139139

140140
ctx.SetTotalCountHeader(count)
141-
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
141+
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
142142
}
143143

144144
// AddTime add time manual to the given issue
@@ -225,7 +225,7 @@ func AddTime(ctx *context.APIContext) {
225225
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
226226
return
227227
}
228-
ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, trackedTime))
228+
ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, user, trackedTime))
229229
}
230230

231231
// ResetIssueTime reset time manual to the given issue
@@ -455,7 +455,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
455455
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
456456
return
457457
}
458-
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
458+
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
459459
}
460460

461461
// ListTrackedTimesByRepository lists all tracked times of the repository
@@ -567,7 +567,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
567567
}
568568

569569
ctx.SetTotalCountHeader(count)
570-
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
570+
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
571571
}
572572

573573
// ListMyTrackedTimes lists all tracked times of the current user
@@ -629,5 +629,5 @@ func ListMyTrackedTimes(ctx *context.APIContext) {
629629
}
630630

631631
ctx.SetTotalCountHeader(count)
632-
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
632+
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes))
633633
}

routers/web/repo/issue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ func GetIssueInfo(ctx *context.Context) {
21792179
}
21802180
}
21812181

2182-
ctx.JSON(http.StatusOK, convert.ToIssue(ctx, issue))
2182+
ctx.JSON(http.StatusOK, convert.ToIssue(ctx, ctx.Doer, issue))
21832183
}
21842184

21852185
// UpdateIssueTitle change issue's title
@@ -2709,7 +2709,7 @@ func SearchIssues(ctx *context.Context) {
27092709
}
27102710

27112711
ctx.SetTotalCountHeader(total)
2712-
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, issues))
2712+
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, ctx.Doer, issues))
27132713
}
27142714

27152715
func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
@@ -2879,7 +2879,7 @@ func ListIssues(ctx *context.Context) {
28792879
}
28802880

28812881
ctx.SetTotalCountHeader(total)
2882-
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, issues))
2882+
ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, ctx.Doer, issues))
28832883
}
28842884

28852885
func BatchDeleteIssues(ctx *context.Context) {

services/actions/notifier.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (n *actionsNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu
4949
newNotifyInputFromIssue(issue, webhook_module.HookEventIssues).WithPayload(&api.IssuePayload{
5050
Action: api.HookIssueOpened,
5151
Index: issue.Index,
52-
Issue: convert.ToAPIIssue(ctx, issue),
52+
Issue: convert.ToAPIIssue(ctx, issue.Poster, issue),
5353
Repository: convert.ToRepo(ctx, issue.Repo, permission),
5454
Sender: convert.ToUser(ctx, issue.Poster, nil),
5555
}).Notify(withMethod(ctx, "NewIssue"))
@@ -89,7 +89,7 @@ func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_mod
8989
WithPayload(&api.IssuePayload{
9090
Action: api.HookIssueEdited,
9191
Index: issue.Index,
92-
Issue: convert.ToAPIIssue(ctx, issue),
92+
Issue: convert.ToAPIIssue(ctx, doer, issue),
9393
Repository: convert.ToRepo(ctx, issue.Repo, permission),
9494
Sender: convert.ToUser(ctx, doer, nil),
9595
}).
@@ -127,7 +127,7 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
127127
}
128128
apiIssue := &api.IssuePayload{
129129
Index: issue.Index,
130-
Issue: convert.ToAPIIssue(ctx, issue),
130+
Issue: convert.ToAPIIssue(ctx, doer, issue),
131131
Repository: convert.ToRepo(ctx, issue.Repo, permission),
132132
Sender: convert.ToUser(ctx, doer, nil),
133133
}
@@ -229,7 +229,7 @@ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues
229229
WithPayload(&api.IssuePayload{
230230
Action: action,
231231
Index: issue.Index,
232-
Issue: convert.ToAPIIssue(ctx, issue),
232+
Issue: convert.ToAPIIssue(ctx, doer, issue),
233233
Repository: convert.ToRepo(ctx, issue.Repo, permission),
234234
Sender: convert.ToUser(ctx, doer, nil),
235235
}).
@@ -293,7 +293,7 @@ func notifyIssueCommentChange(ctx context.Context, doer *user_model.User, commen
293293

294294
payload := &api.IssueCommentPayload{
295295
Action: action,
296-
Issue: convert.ToAPIIssue(ctx, comment.Issue),
296+
Issue: convert.ToAPIIssue(ctx, doer, comment.Issue),
297297
Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment),
298298
Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission),
299299
Sender: convert.ToUser(ctx, doer, nil),

services/convert/issue.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ import (
1818
api "code.gitea.io/gitea/modules/structs"
1919
)
2020

21-
func ToIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
22-
return toIssue(ctx, issue, WebAssetDownloadURL)
21+
func ToIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) *api.Issue {
22+
return toIssue(ctx, doer, issue, WebAssetDownloadURL)
2323
}
2424

2525
// ToAPIIssue converts an Issue to API format
2626
// it assumes some fields assigned with values:
2727
// Required - Poster, Labels,
2828
// Optional - Milestone, Assignee, PullRequest
29-
func ToAPIIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
30-
return toIssue(ctx, issue, APIAssetDownloadURL)
29+
func ToAPIIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) *api.Issue {
30+
return toIssue(ctx, doer, issue, APIAssetDownloadURL)
3131
}
3232

33-
func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func(repo *repo_model.Repository, attach *repo_model.Attachment) string) *api.Issue {
33+
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 {
3434
if err := issue.LoadLabels(ctx); err != nil {
3535
return &api.Issue{}
3636
}
@@ -44,7 +44,7 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func
4444
apiIssue := &api.Issue{
4545
ID: issue.ID,
4646
Index: issue.Index,
47-
Poster: ToUser(ctx, issue.Poster, nil),
47+
Poster: ToUser(ctx, issue.Poster, doer),
4848
Title: issue.Title,
4949
Body: issue.Content,
5050
Attachments: toAttachments(issue.Repo, issue.Attachments, getDownloadURL),
@@ -114,25 +114,25 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func
114114
}
115115

116116
// ToIssueList converts an IssueList to API format
117-
func ToIssueList(ctx context.Context, il issues_model.IssueList) []*api.Issue {
117+
func ToIssueList(ctx context.Context, doer *user_model.User, il issues_model.IssueList) []*api.Issue {
118118
result := make([]*api.Issue, len(il))
119119
for i := range il {
120-
result[i] = ToIssue(ctx, il[i])
120+
result[i] = ToIssue(ctx, doer, il[i])
121121
}
122122
return result
123123
}
124124

125125
// ToAPIIssueList converts an IssueList to API format
126-
func ToAPIIssueList(ctx context.Context, il issues_model.IssueList) []*api.Issue {
126+
func ToAPIIssueList(ctx context.Context, doer *user_model.User, il issues_model.IssueList) []*api.Issue {
127127
result := make([]*api.Issue, len(il))
128128
for i := range il {
129-
result[i] = ToAPIIssue(ctx, il[i])
129+
result[i] = ToAPIIssue(ctx, doer, il[i])
130130
}
131131
return result
132132
}
133133

134134
// ToTrackedTime converts TrackedTime to API format
135-
func ToTrackedTime(ctx context.Context, t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
135+
func ToTrackedTime(ctx context.Context, doer *user_model.User, t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
136136
apiT = &api.TrackedTime{
137137
ID: t.ID,
138138
IssueID: t.IssueID,
@@ -141,7 +141,7 @@ func ToTrackedTime(ctx context.Context, t *issues_model.TrackedTime) (apiT *api.
141141
Created: t.Created,
142142
}
143143
if t.Issue != nil {
144-
apiT.Issue = ToAPIIssue(ctx, t.Issue)
144+
apiT.Issue = ToAPIIssue(ctx, doer, t.Issue)
145145
}
146146
if t.User != nil {
147147
apiT.UserName = t.User.Name
@@ -192,10 +192,10 @@ func ToStopWatches(ctx context.Context, sws []*issues_model.Stopwatch) (api.Stop
192192
}
193193

194194
// ToTrackedTimeList converts TrackedTimeList to API format
195-
func ToTrackedTimeList(ctx context.Context, tl issues_model.TrackedTimeList) api.TrackedTimeList {
195+
func ToTrackedTimeList(ctx context.Context, doer *user_model.User, tl issues_model.TrackedTimeList) api.TrackedTimeList {
196196
result := make([]*api.TrackedTime, 0, len(tl))
197197
for _, t := range tl {
198-
result = append(result, ToTrackedTime(ctx, t))
198+
result = append(result, ToTrackedTime(ctx, doer, t))
199199
}
200200
return result
201201
}

services/convert/issue_comment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
120120
return nil
121121
}
122122

123-
comment.TrackedTime = ToTrackedTime(ctx, c.Time)
123+
comment.TrackedTime = ToTrackedTime(ctx, doer, c.Time)
124124
}
125125

126126
if c.RefIssueID != 0 {
@@ -129,7 +129,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
129129
log.Error("GetIssueByID(%d): %v", c.RefIssueID, err)
130130
return nil
131131
}
132-
comment.RefIssue = ToAPIIssue(ctx, issue)
132+
comment.RefIssue = ToAPIIssue(ctx, doer, issue)
133133
}
134134

135135
if c.RefCommentID != 0 {
@@ -180,7 +180,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
180180
}
181181

182182
if c.DependentIssue != nil {
183-
comment.DependentIssue = ToAPIIssue(ctx, c.DependentIssue)
183+
comment.DependentIssue = ToAPIIssue(ctx, doer, c.DependentIssue)
184184
}
185185

186186
return comment

services/convert/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u
3333
return nil
3434
}
3535

36-
apiIssue := ToAPIIssue(ctx, pr.Issue)
36+
apiIssue := ToAPIIssue(ctx, doer, pr.Issue)
3737
if err := pr.LoadBaseRepo(ctx); err != nil {
3838
log.Error("GetRepositoryById[%d]: %v", pr.ID, err)
3939
return nil

0 commit comments

Comments
 (0)