loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix missed doer (#30231)

Fix #29879

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit 908426aa0fcc58961c345994f0f66056f6cf5f48)

authored by

Lunny Xiao
Giteabot
and committed by
Gergely Nagy
f544bb25 84abf4bd

+55 -55
+5 -5
routers/api/v1/repo/issue.go
··· 311 311 312 312 ctx.SetLinkHeader(int(total), limit) 313 313 ctx.SetTotalCountHeader(total) 314 - ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues)) 314 + ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues)) 315 315 } 316 316 317 317 // ListIssues list the issues of a repository ··· 548 548 549 549 ctx.SetLinkHeader(int(total), listOptions.PageSize) 550 550 ctx.SetTotalCountHeader(total) 551 - ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues)) 551 + ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues)) 552 552 } 553 553 554 554 func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 { ··· 614 614 ctx.NotFound() 615 615 return 616 616 } 617 - ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue)) 617 + ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, ctx.Doer, issue)) 618 618 } 619 619 620 620 // CreateIssue create an issue of a repository ··· 737 737 ctx.Error(http.StatusInternalServerError, "GetIssueByID", err) 738 738 return 739 739 } 740 - ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue)) 740 + ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue)) 741 741 } 742 742 743 743 // EditIssue modify an issue of a repository ··· 913 913 ctx.InternalServerError(err) 914 914 return 915 915 } 916 - ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue)) 916 + ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, issue)) 917 917 } 918 918 919 919 func DeleteIssue(ctx *context.APIContext) {
+1 -1
routers/api/v1/repo/issue_attachment.go
··· 108 108 return 109 109 } 110 110 111 - ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue).Attachments) 111 + ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, ctx.Doer, issue).Attachments) 112 112 } 113 113 114 114 // CreateIssueAttachment creates an attachment and saves the given file
+6 -6
routers/api/v1/repo/issue_dependency.go
··· 153 153 blockerIssues = append(blockerIssues, &blocker.Issue) 154 154 } 155 155 156 - ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, blockerIssues)) 156 + ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, blockerIssues)) 157 157 } 158 158 159 159 // CreateIssueDependency create a new issue dependencies ··· 214 214 return 215 215 } 216 216 217 - ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target)) 217 + ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target)) 218 218 } 219 219 220 220 // RemoveIssueDependency remove an issue dependency ··· 275 275 return 276 276 } 277 277 278 - ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, target)) 278 + ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, target)) 279 279 } 280 280 281 281 // GetIssueBlocks list issues that are blocked by this issue ··· 381 381 issues = append(issues, &depMeta.Issue) 382 382 } 383 383 384 - ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues)) 384 + ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues)) 385 385 } 386 386 387 387 // CreateIssueBlocking block the issue given in the body by the issue in path ··· 438 438 return 439 439 } 440 440 441 - ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, dependency)) 441 + ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, dependency)) 442 442 } 443 443 444 444 // RemoveIssueBlocking unblock the issue given in the body by the issue in path ··· 495 495 return 496 496 } 497 497 498 - ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, dependency)) 498 + ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, ctx.Doer, dependency)) 499 499 } 500 500 501 501 func getParamsIssue(ctx *context.APIContext) *issues_model.Issue {
+1 -1
routers/api/v1/repo/issue_pin.go
··· 207 207 return 208 208 } 209 209 210 - ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues)) 210 + ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, ctx.Doer, issues)) 211 211 } 212 212 213 213 // ListPinnedPullRequests returns a list of all pinned PRs
+5 -5
routers/api/v1/repo/issue_tracked_time.go
··· 138 138 } 139 139 140 140 ctx.SetTotalCountHeader(count) 141 - ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes)) 141 + ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes)) 142 142 } 143 143 144 144 // AddTime add time manual to the given issue ··· 225 225 ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) 226 226 return 227 227 } 228 - ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, trackedTime)) 228 + ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, user, trackedTime)) 229 229 } 230 230 231 231 // ResetIssueTime reset time manual to the given issue ··· 455 455 ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) 456 456 return 457 457 } 458 - ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes)) 458 + ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes)) 459 459 } 460 460 461 461 // ListTrackedTimesByRepository lists all tracked times of the repository ··· 567 567 } 568 568 569 569 ctx.SetTotalCountHeader(count) 570 - ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes)) 570 + ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes)) 571 571 } 572 572 573 573 // ListMyTrackedTimes lists all tracked times of the current user ··· 629 629 } 630 630 631 631 ctx.SetTotalCountHeader(count) 632 - ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes)) 632 + ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, ctx.Doer, trackedTimes)) 633 633 }
+3 -3
routers/web/repo/issue.go
··· 2174 2174 } 2175 2175 } 2176 2176 2177 - ctx.JSON(http.StatusOK, convert.ToIssue(ctx, issue)) 2177 + ctx.JSON(http.StatusOK, convert.ToIssue(ctx, ctx.Doer, issue)) 2178 2178 } 2179 2179 2180 2180 // UpdateIssueTitle change issue's title ··· 2708 2708 } 2709 2709 2710 2710 ctx.SetTotalCountHeader(total) 2711 - ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, issues)) 2711 + ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, ctx.Doer, issues)) 2712 2712 } 2713 2713 2714 2714 func getUserIDForFilter(ctx *context.Context, queryName string) int64 { ··· 2878 2878 } 2879 2879 2880 2880 ctx.SetTotalCountHeader(total) 2881 - ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, issues)) 2881 + ctx.JSON(http.StatusOK, convert.ToIssueList(ctx, ctx.Doer, issues)) 2882 2882 } 2883 2883 2884 2884 func BatchDeleteIssues(ctx *context.Context) {
+5 -5
services/actions/notifier.go
··· 49 49 newNotifyInputFromIssue(issue, webhook_module.HookEventIssues).WithPayload(&api.IssuePayload{ 50 50 Action: api.HookIssueOpened, 51 51 Index: issue.Index, 52 - Issue: convert.ToAPIIssue(ctx, issue), 52 + Issue: convert.ToAPIIssue(ctx, issue.Poster, issue), 53 53 Repository: convert.ToRepo(ctx, issue.Repo, permission), 54 54 Sender: convert.ToUser(ctx, issue.Poster, nil), 55 55 }).Notify(withMethod(ctx, "NewIssue")) ··· 89 89 WithPayload(&api.IssuePayload{ 90 90 Action: api.HookIssueEdited, 91 91 Index: issue.Index, 92 - Issue: convert.ToAPIIssue(ctx, issue), 92 + Issue: convert.ToAPIIssue(ctx, doer, issue), 93 93 Repository: convert.ToRepo(ctx, issue.Repo, permission), 94 94 Sender: convert.ToUser(ctx, doer, nil), 95 95 }). ··· 127 127 } 128 128 apiIssue := &api.IssuePayload{ 129 129 Index: issue.Index, 130 - Issue: convert.ToAPIIssue(ctx, issue), 130 + Issue: convert.ToAPIIssue(ctx, doer, issue), 131 131 Repository: convert.ToRepo(ctx, issue.Repo, permission), 132 132 Sender: convert.ToUser(ctx, doer, nil), 133 133 } ··· 229 229 WithPayload(&api.IssuePayload{ 230 230 Action: action, 231 231 Index: issue.Index, 232 - Issue: convert.ToAPIIssue(ctx, issue), 232 + Issue: convert.ToAPIIssue(ctx, doer, issue), 233 233 Repository: convert.ToRepo(ctx, issue.Repo, permission), 234 234 Sender: convert.ToUser(ctx, doer, nil), 235 235 }). ··· 293 293 294 294 payload := &api.IssueCommentPayload{ 295 295 Action: action, 296 - Issue: convert.ToAPIIssue(ctx, comment.Issue), 296 + Issue: convert.ToAPIIssue(ctx, doer, comment.Issue), 297 297 Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment), 298 298 Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission), 299 299 Sender: convert.ToUser(ctx, doer, nil),
+14 -14
services/convert/issue.go
··· 18 18 api "code.gitea.io/gitea/modules/structs" 19 19 ) 20 20 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) 23 23 } 24 24 25 25 // ToAPIIssue converts an Issue to API format 26 26 // it assumes some fields assigned with values: 27 27 // Required - Poster, Labels, 28 28 // 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) 31 31 } 32 32 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 { 34 34 if err := issue.LoadLabels(ctx); err != nil { 35 35 return &api.Issue{} 36 36 } ··· 44 44 apiIssue := &api.Issue{ 45 45 ID: issue.ID, 46 46 Index: issue.Index, 47 - Poster: ToUser(ctx, issue.Poster, nil), 47 + Poster: ToUser(ctx, issue.Poster, doer), 48 48 Title: issue.Title, 49 49 Body: issue.Content, 50 50 Attachments: toAttachments(issue.Repo, issue.Attachments, getDownloadURL), ··· 114 114 } 115 115 116 116 // 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 { 118 118 result := make([]*api.Issue, len(il)) 119 119 for i := range il { 120 - result[i] = ToIssue(ctx, il[i]) 120 + result[i] = ToIssue(ctx, doer, il[i]) 121 121 } 122 122 return result 123 123 } 124 124 125 125 // 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 { 127 127 result := make([]*api.Issue, len(il)) 128 128 for i := range il { 129 - result[i] = ToAPIIssue(ctx, il[i]) 129 + result[i] = ToAPIIssue(ctx, doer, il[i]) 130 130 } 131 131 return result 132 132 } 133 133 134 134 // 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) { 136 136 apiT = &api.TrackedTime{ 137 137 ID: t.ID, 138 138 IssueID: t.IssueID, ··· 141 141 Created: t.Created, 142 142 } 143 143 if t.Issue != nil { 144 - apiT.Issue = ToAPIIssue(ctx, t.Issue) 144 + apiT.Issue = ToAPIIssue(ctx, doer, t.Issue) 145 145 } 146 146 if t.User != nil { 147 147 apiT.UserName = t.User.Name ··· 192 192 } 193 193 194 194 // 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 { 196 196 result := make([]*api.TrackedTime, 0, len(tl)) 197 197 for _, t := range tl { 198 - result = append(result, ToTrackedTime(ctx, t)) 198 + result = append(result, ToTrackedTime(ctx, doer, t)) 199 199 } 200 200 return result 201 201 }
+3 -3
services/convert/issue_comment.go
··· 120 120 return nil 121 121 } 122 122 123 - comment.TrackedTime = ToTrackedTime(ctx, c.Time) 123 + comment.TrackedTime = ToTrackedTime(ctx, doer, c.Time) 124 124 } 125 125 126 126 if c.RefIssueID != 0 { ··· 129 129 log.Error("GetIssueByID(%d): %v", c.RefIssueID, err) 130 130 return nil 131 131 } 132 - comment.RefIssue = ToAPIIssue(ctx, issue) 132 + comment.RefIssue = ToAPIIssue(ctx, doer, issue) 133 133 } 134 134 135 135 if c.RefCommentID != 0 { ··· 180 180 } 181 181 182 182 if c.DependentIssue != nil { 183 - comment.DependentIssue = ToAPIIssue(ctx, c.DependentIssue) 183 + comment.DependentIssue = ToAPIIssue(ctx, doer, c.DependentIssue) 184 184 } 185 185 186 186 return comment
+1 -1
services/convert/pull.go
··· 33 33 return nil 34 34 } 35 35 36 - apiIssue := ToAPIIssue(ctx, pr.Issue) 36 + apiIssue := ToAPIIssue(ctx, doer, pr.Issue) 37 37 if err := pr.LoadBaseRepo(ctx); err != nil { 38 38 log.Error("GetRepositoryById[%d]: %v", pr.ID, err) 39 39 return nil
+11 -11
services/webhook/notifier.go
··· 67 67 err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{ 68 68 Action: api.HookIssueLabelCleared, 69 69 Index: issue.Index, 70 - Issue: convert.ToAPIIssue(ctx, issue), 70 + Issue: convert.ToAPIIssue(ctx, doer, issue), 71 71 Repository: convert.ToRepo(ctx, issue.Repo, permission), 72 72 Sender: convert.ToUser(ctx, doer, nil), 73 73 }) ··· 168 168 permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer) 169 169 apiIssue := &api.IssuePayload{ 170 170 Index: issue.Index, 171 - Issue: convert.ToAPIIssue(ctx, issue), 171 + Issue: convert.ToAPIIssue(ctx, doer, issue), 172 172 Repository: convert.ToRepo(ctx, issue.Repo, permission), 173 173 Sender: convert.ToUser(ctx, doer, nil), 174 174 } ··· 214 214 From: oldTitle, 215 215 }, 216 216 }, 217 - Issue: convert.ToAPIIssue(ctx, issue), 217 + Issue: convert.ToAPIIssue(ctx, doer, issue), 218 218 Repository: convert.ToRepo(ctx, issue.Repo, permission), 219 219 Sender: convert.ToUser(ctx, doer, nil), 220 220 }) ··· 250 250 } else { 251 251 apiIssue := &api.IssuePayload{ 252 252 Index: issue.Index, 253 - Issue: convert.ToAPIIssue(ctx, issue), 253 + Issue: convert.ToAPIIssue(ctx, doer, issue), 254 254 Repository: convert.ToRepo(ctx, issue.Repo, permission), 255 255 Sender: convert.ToUser(ctx, doer, nil), 256 256 CommitID: commitID, ··· 281 281 if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssues, &api.IssuePayload{ 282 282 Action: api.HookIssueOpened, 283 283 Index: issue.Index, 284 - Issue: convert.ToAPIIssue(ctx, issue), 284 + Issue: convert.ToAPIIssue(ctx, issue.Poster, issue), 285 285 Repository: convert.ToRepo(ctx, issue.Repo, permission), 286 286 Sender: convert.ToUser(ctx, issue.Poster, nil), 287 287 }); err != nil { ··· 349 349 From: oldContent, 350 350 }, 351 351 }, 352 - Issue: convert.ToAPIIssue(ctx, issue), 352 + Issue: convert.ToAPIIssue(ctx, doer, issue), 353 353 Repository: convert.ToRepo(ctx, issue.Repo, permission), 354 354 Sender: convert.ToUser(ctx, doer, nil), 355 355 }) ··· 384 384 permission, _ := access_model.GetUserRepoPermission(ctx, c.Issue.Repo, doer) 385 385 if err := PrepareWebhooks(ctx, EventSource{Repository: c.Issue.Repo}, eventType, &api.IssueCommentPayload{ 386 386 Action: api.HookIssueCommentEdited, 387 - Issue: convert.ToAPIIssue(ctx, c.Issue), 387 + Issue: convert.ToAPIIssue(ctx, doer, c.Issue), 388 388 Comment: convert.ToAPIComment(ctx, c.Issue.Repo, c), 389 389 Changes: &api.ChangesPayload{ 390 390 Body: &api.ChangesFromPayload{ ··· 412 412 permission, _ := access_model.GetUserRepoPermission(ctx, repo, doer) 413 413 if err := PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, eventType, &api.IssueCommentPayload{ 414 414 Action: api.HookIssueCommentCreated, 415 - Issue: convert.ToAPIIssue(ctx, issue), 415 + Issue: convert.ToAPIIssue(ctx, doer, issue), 416 416 Comment: convert.ToAPIComment(ctx, repo, comment), 417 417 Repository: convert.ToRepo(ctx, repo, permission), 418 418 Sender: convert.ToUser(ctx, doer, nil), ··· 449 449 permission, _ := access_model.GetUserRepoPermission(ctx, comment.Issue.Repo, doer) 450 450 if err := PrepareWebhooks(ctx, EventSource{Repository: comment.Issue.Repo}, eventType, &api.IssueCommentPayload{ 451 451 Action: api.HookIssueCommentDeleted, 452 - Issue: convert.ToAPIIssue(ctx, comment.Issue), 452 + Issue: convert.ToAPIIssue(ctx, doer, comment.Issue), 453 453 Comment: convert.ToAPIComment(ctx, comment.Issue.Repo, comment), 454 454 Repository: convert.ToRepo(ctx, comment.Issue.Repo, permission), 455 455 Sender: convert.ToUser(ctx, doer, nil), ··· 533 533 err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueLabel, &api.IssuePayload{ 534 534 Action: api.HookIssueLabelUpdated, 535 535 Index: issue.Index, 536 - Issue: convert.ToAPIIssue(ctx, issue), 536 + Issue: convert.ToAPIIssue(ctx, doer, issue), 537 537 Repository: convert.ToRepo(ctx, issue.Repo, permission), 538 538 Sender: convert.ToUser(ctx, doer, nil), 539 539 }) ··· 575 575 err = PrepareWebhooks(ctx, EventSource{Repository: issue.Repo}, webhook_module.HookEventIssueMilestone, &api.IssuePayload{ 576 576 Action: hookAction, 577 577 Index: issue.Index, 578 - Issue: convert.ToAPIIssue(ctx, issue), 578 + Issue: convert.ToAPIIssue(ctx, doer, issue), 579 579 Repository: convert.ToRepo(ctx, issue.Repo, permission), 580 580 Sender: convert.ToUser(ctx, doer, nil), 581 581 })