aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/issue.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/repo/issue.go')
-rw-r--r--routers/web/repo/issue.go154
1 files changed, 77 insertions, 77 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index a81b1f1962..18f352265f 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -77,7 +77,7 @@ func MustAllowUserComment(ctx *context.Context) {
return
}
- if issue.IsLocked && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) && !ctx.User.IsAdmin {
+ if issue.IsLocked && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) && !ctx.Doer.IsAdmin {
ctx.Flash.Error(ctx.Tr("repo.issues.comment_on_locked"))
ctx.Redirect(issue.HTMLURL())
return
@@ -107,9 +107,9 @@ func MustAllowPulls(ctx *context.Context) {
}
// User can send pull request if owns a forked repository.
- if ctx.IsSigned && repo_model.HasForkedRepo(ctx.User.ID, ctx.Repo.Repository.ID) {
+ if ctx.IsSigned && repo_model.HasForkedRepo(ctx.Doer.ID, ctx.Repo.Repository.ID) {
ctx.Repo.PullRequest.Allowed = true
- ctx.Repo.PullRequest.HeadInfoSubURL = url.PathEscape(ctx.User.Name) + ":" + util.PathEscapeSegments(ctx.Repo.BranchName)
+ ctx.Repo.PullRequest.HeadInfoSubURL = url.PathEscape(ctx.Doer.Name) + ":" + util.PathEscapeSegments(ctx.Repo.BranchName)
}
}
@@ -133,13 +133,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
if ctx.IsSigned {
switch viewType {
case "created_by":
- posterID = ctx.User.ID
+ posterID = ctx.Doer.ID
case "mentioned":
- mentionedID = ctx.User.ID
+ mentionedID = ctx.Doer.ID
case "assigned":
- assigneeID = ctx.User.ID
+ assigneeID = ctx.Doer.ID
case "review_requested":
- reviewRequestedID = ctx.User.ID
+ reviewRequestedID = ctx.Doer.ID
}
}
@@ -259,7 +259,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
// Check read status
if !ctx.IsSigned {
issues[i].IsRead = true
- } else if err = issues[i].GetIsRead(ctx.User.ID); err != nil {
+ } else if err = issues[i].GetIsRead(ctx.Doer.ID); err != nil {
ctx.ServerError("GetIsRead", err)
return
}
@@ -514,7 +514,7 @@ func RetrieveRepoReviewers(ctx *context.Context, repo *repo_model.Repository, is
posterID = 0
}
- reviewers, err = models.GetReviewers(repo, ctx.User.ID, posterID)
+ reviewers, err = models.GetReviewers(repo, ctx.Doer.ID, posterID)
if err != nil {
ctx.ServerError("GetReviewers", err)
return
@@ -551,11 +551,11 @@ func RetrieveRepoReviewers(ctx *context.Context, repo *repo_model.Repository, is
if ctx.Repo.IsAdmin() {
// Admin can dismiss or re-request any review requests
tmp.CanChange = true
- } else if ctx.User != nil && ctx.User.ID == review.ReviewerID && review.Type == models.ReviewTypeRequest {
+ } else if ctx.Doer != nil && ctx.Doer.ID == review.ReviewerID && review.Type == models.ReviewTypeRequest {
// A user can refuse review requests
tmp.CanChange = true
- } else if (canChooseReviewer || (ctx.User != nil && ctx.User.ID == issue.PosterID)) && review.Type != models.ReviewTypeRequest &&
- ctx.User.ID != review.ReviewerID {
+ } else if (canChooseReviewer || (ctx.Doer != nil && ctx.Doer.ID == issue.PosterID)) && review.Type != models.ReviewTypeRequest &&
+ ctx.Doer.ID != review.ReviewerID {
// The poster of the PR, a manager, or official reviewers can re-request review from other reviewers
tmp.CanChange = true
}
@@ -699,7 +699,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *repo_model.Repository, isPull
ctx.Data["Branches"] = brs
// Contains true if the user can create issue dependencies
- ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User, isPull)
+ ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.Doer, isPull)
return labels
}
@@ -859,7 +859,7 @@ func DeleteIssue(ctx *context.Context) {
return
}
- if err := issue_service.DeleteIssue(ctx.User, ctx.Repo.GitRepo, issue); err != nil {
+ if err := issue_service.DeleteIssue(ctx.Doer, ctx.Repo.GitRepo, issue); err != nil {
ctx.ServerError("DeleteIssueByID", err)
return
}
@@ -1008,8 +1008,8 @@ func NewIssuePost(ctx *context.Context) {
RepoID: repo.ID,
Repo: repo,
Title: form.Title,
- PosterID: ctx.User.ID,
- Poster: ctx.User,
+ PosterID: ctx.Doer.ID,
+ Poster: ctx.Doer,
MilestoneID: milestoneID,
Content: form.Content,
Ref: form.Ref,
@@ -1025,7 +1025,7 @@ func NewIssuePost(ctx *context.Context) {
}
if projectID > 0 {
- if err := models.ChangeProjectAssign(issue, ctx.User, projectID); err != nil {
+ if err := models.ChangeProjectAssign(issue, ctx.Doer, projectID); err != nil {
ctx.ServerError("ChangeProjectAssign", err)
return
}
@@ -1177,10 +1177,10 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
iw := new(models.IssueWatch)
- if ctx.User != nil {
- iw.UserID = ctx.User.ID
+ if ctx.Doer != nil {
+ iw.UserID = ctx.Doer.ID
iw.IssueID = issue.ID
- iw.IsWatching, err = models.CheckIssueWatch(ctx.User, issue)
+ iw.IsWatching, err = models.CheckIssueWatch(ctx.Doer, issue)
if err != nil {
ctx.ServerError("CheckIssueWatch", err)
return
@@ -1260,8 +1260,8 @@ func ViewIssue(ctx *context.Context) {
if issue.IsPull {
canChooseReviewer := ctx.Repo.CanWrite(unit.TypePullRequests)
- if !canChooseReviewer && ctx.User != nil && ctx.IsSigned {
- canChooseReviewer, err = models.IsOfficialReviewer(issue, ctx.User)
+ if !canChooseReviewer && ctx.Doer != nil && ctx.IsSigned {
+ canChooseReviewer, err = models.IsOfficialReviewer(issue, ctx.Doer)
if err != nil {
ctx.ServerError("IsOfficialReviewer", err)
return
@@ -1276,7 +1276,7 @@ func ViewIssue(ctx *context.Context) {
if ctx.IsSigned {
// Update issue-user.
- if err = issue.ReadBy(ctx.User.ID); err != nil {
+ if err = issue.ReadBy(ctx.Doer.ID); err != nil {
ctx.ServerError("ReadBy", err)
return
}
@@ -1292,11 +1292,11 @@ func ViewIssue(ctx *context.Context) {
if ctx.Repo.Repository.IsTimetrackerEnabled() {
if ctx.IsSigned {
// Deal with the stopwatch
- ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.User.ID, issue.ID)
+ ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.Doer.ID, issue.ID)
if !ctx.Data["IsStopwatchRunning"].(bool) {
var exists bool
var sw *models.Stopwatch
- if exists, sw, err = models.HasUserStopwatch(ctx.User.ID); err != nil {
+ if exists, sw, err = models.HasUserStopwatch(ctx.Doer.ID); err != nil {
ctx.ServerError("HasUserStopwatch", err)
return
}
@@ -1316,7 +1316,7 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["OtherStopwatchURL"] = otherIssue.HTMLURL()
}
}
- ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.User)
+ ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.Doer)
} else {
ctx.Data["CanUseTimetracker"] = false
}
@@ -1327,7 +1327,7 @@ func ViewIssue(ctx *context.Context) {
}
// Check if the user can use the dependencies
- ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User, issue.IsPull)
+ ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.Doer, issue.IsPull)
// check if dependencies can be created across repositories
ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies
@@ -1511,7 +1511,7 @@ func ViewIssue(ctx *context.Context) {
if err := pull.LoadHeadRepo(); err != nil {
log.Error("LoadHeadRepo: %v", err)
} else if pull.HeadRepo != nil && pull.HeadBranch != pull.HeadRepo.DefaultBranch {
- perm, err := models.GetUserRepoPermission(pull.HeadRepo, ctx.User)
+ perm, err := models.GetUserRepoPermission(pull.HeadRepo, ctx.Doer)
if err != nil {
ctx.ServerError("GetUserRepoPermission", err)
return
@@ -1530,18 +1530,18 @@ func ViewIssue(ctx *context.Context) {
if err := pull.LoadBaseRepo(); err != nil {
log.Error("LoadBaseRepo: %v", err)
}
- perm, err := models.GetUserRepoPermission(pull.BaseRepo, ctx.User)
+ perm, err := models.GetUserRepoPermission(pull.BaseRepo, ctx.Doer)
if err != nil {
ctx.ServerError("GetUserRepoPermission", err)
return
}
- ctx.Data["AllowMerge"], err = pull_service.IsUserAllowedToMerge(pull, perm, ctx.User)
+ ctx.Data["AllowMerge"], err = pull_service.IsUserAllowedToMerge(pull, perm, ctx.Doer)
if err != nil {
ctx.ServerError("IsUserAllowedToMerge", err)
return
}
- if ctx.Data["CanMarkConversation"], err = models.CanMarkConversation(issue, ctx.User); err != nil {
+ if ctx.Data["CanMarkConversation"], err = models.CanMarkConversation(issue, ctx.Doer); err != nil {
ctx.ServerError("CanMarkConversation", err)
return
}
@@ -1581,8 +1581,8 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["ShowMergeInstructions"] = true
if pull.ProtectedBranch != nil {
var showMergeInstructions bool
- if ctx.User != nil {
- showMergeInstructions = pull.ProtectedBranch.CanUserPush(ctx.User.ID)
+ if ctx.Doer != nil {
+ showMergeInstructions = pull.ProtectedBranch.CanUserPush(ctx.Doer.ID)
}
cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull)
ctx.Data["IsBlockedByApprovals"] = !pull.ProtectedBranch.HasEnoughApprovals(pull)
@@ -1597,8 +1597,8 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["ShowMergeInstructions"] = showMergeInstructions
}
ctx.Data["WillSign"] = false
- if ctx.User != nil {
- sign, key, _, err := asymkey_service.SignMerge(ctx, pull, ctx.User, pull.BaseRepo.RepoPath(), pull.BaseBranch, pull.GetGitRefName())
+ if ctx.Doer != nil {
+ sign, key, _, err := asymkey_service.SignMerge(ctx, pull, ctx.Doer, pull.BaseRepo.RepoPath(), pull.BaseBranch, pull.GetGitRefName())
ctx.Data["WillSign"] = sign
ctx.Data["SigningKey"] = key
if err != nil {
@@ -1636,7 +1636,7 @@ func ViewIssue(ctx *context.Context) {
if pull.CanAutoMerge() || pull.IsWorkInProgress() || pull.IsChecking() {
return false
}
- if (ctx.User.IsAdmin || ctx.Repo.IsAdmin()) && prConfig.AllowManualMerge {
+ if (ctx.Doer.IsAdmin || ctx.Repo.IsAdmin()) && prConfig.AllowManualMerge {
return true
}
@@ -1663,16 +1663,16 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Issue"] = issue
ctx.Data["Reference"] = issue.Ref
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + url.QueryEscape(ctx.Data["Link"].(string))
- ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
+ ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.Doer.ID)
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
ctx.Data["HasProjectsWritePermission"] = ctx.Repo.CanWrite(unit.TypeProjects)
- ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin)
+ ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.Doer.IsAdmin)
ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons
ctx.Data["RefEndName"] = git.RefEndName(issue.Ref)
var hiddenCommentTypes *big.Int
if ctx.IsSigned {
- val, err := user_model.GetUserSetting(ctx.User.ID, user_model.SettingsKeyHiddenCommentTypes)
+ val, err := user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
if err != nil {
ctx.ServerError("GetUserSetting", err)
return
@@ -1754,7 +1754,7 @@ func UpdateIssueTitle(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
+ if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
return
}
@@ -1765,7 +1765,7 @@ func UpdateIssueTitle(ctx *context.Context) {
return
}
- if err := issue_service.ChangeTitle(issue, ctx.User, title); err != nil {
+ if err := issue_service.ChangeTitle(issue, ctx.Doer, title); err != nil {
ctx.ServerError("ChangeTitle", err)
return
}
@@ -1782,14 +1782,14 @@ func UpdateIssueRef(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) || issue.IsPull {
+ if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) || issue.IsPull {
ctx.Error(http.StatusForbidden)
return
}
ref := ctx.FormTrim("ref")
- if err := issue_service.ChangeIssueRef(issue, ctx.User, ref); err != nil {
+ if err := issue_service.ChangeIssueRef(issue, ctx.Doer, ref); err != nil {
ctx.ServerError("ChangeRef", err)
return
}
@@ -1806,12 +1806,12 @@ func UpdateIssueContent(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
+ if !ctx.IsSigned || (ctx.Doer.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
return
}
- if err := issue_service.ChangeContent(issue, ctx.User, ctx.Req.FormValue("content")); err != nil {
+ if err := issue_service.ChangeContent(issue, ctx.Doer, ctx.Req.FormValue("content")); err != nil {
ctx.ServerError("ChangeContent", err)
return
}
@@ -1855,7 +1855,7 @@ func UpdateIssueMilestone(ctx *context.Context) {
continue
}
issue.MilestoneID = milestoneID
- if err := issue_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
+ if err := issue_service.ChangeMilestoneAssign(issue, ctx.Doer, oldMilestoneID); err != nil {
ctx.ServerError("ChangeMilestoneAssign", err)
return
}
@@ -1879,7 +1879,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
for _, issue := range issues {
switch action {
case "clear":
- if err := issue_service.DeleteNotPassedAssignee(issue, ctx.User, []*user_model.User{}); err != nil {
+ if err := issue_service.DeleteNotPassedAssignee(issue, ctx.Doer, []*user_model.User{}); err != nil {
ctx.ServerError("ClearAssignees", err)
return
}
@@ -1900,7 +1900,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
return
}
- _, _, err = issue_service.ToggleAssignee(issue, ctx.User, assigneeID)
+ _, _, err = issue_service.ToggleAssignee(issue, ctx.Doer, assigneeID)
if err != nil {
ctx.ServerError("ToggleAssignee", err)
return
@@ -1972,7 +1972,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
return
}
- err = issue_service.IsValidTeamReviewRequest(team, ctx.User, action == "attach", issue)
+ err = issue_service.IsValidTeamReviewRequest(team, ctx.Doer, action == "attach", issue)
if err != nil {
if models.IsErrNotValidReviewRequest(err) {
log.Warn(
@@ -1987,7 +1987,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
return
}
- _, err = issue_service.TeamReviewRequest(issue, ctx.User, team, action == "attach")
+ _, err = issue_service.TeamReviewRequest(issue, ctx.Doer, team, action == "attach")
if err != nil {
ctx.ServerError("TeamReviewRequest", err)
return
@@ -2010,7 +2010,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
return
}
- err = issue_service.IsValidReviewRequest(reviewer, ctx.User, action == "attach", issue, nil)
+ err = issue_service.IsValidReviewRequest(reviewer, ctx.Doer, action == "attach", issue, nil)
if err != nil {
if models.IsErrNotValidReviewRequest(err) {
log.Warn(
@@ -2025,7 +2025,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
return
}
- _, err = issue_service.ReviewRequest(issue, ctx.User, reviewer, action == "attach")
+ _, err = issue_service.ReviewRequest(issue, ctx.Doer, reviewer, action == "attach")
if err != nil {
ctx.ServerError("ReviewRequest", err)
return
@@ -2060,7 +2060,7 @@ func UpdateIssueStatus(ctx *context.Context) {
}
for _, issue := range issues {
if issue.IsClosed != isClosed {
- if err := issue_service.ChangeStatus(issue, ctx.User, isClosed); err != nil {
+ if err := issue_service.ChangeStatus(issue, ctx.Doer, isClosed); err != nil {
if models.IsErrDependenciesLeft(err) {
ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{
"error": "cannot close this issue because it still has open dependencies",
@@ -2085,7 +2085,7 @@ func NewComment(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
+ if !ctx.IsSigned || (ctx.Doer.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
if log.IsTrace() {
if ctx.IsSigned {
issueType := "issues"
@@ -2094,7 +2094,7 @@ func NewComment(ctx *context.Context) {
}
log.Trace("Permission Denied: User %-v not the Poster (ID: %d) and cannot read %s in Repo %-v.\n"+
"User in Repo has Permissions: %-+v",
- ctx.User,
+ ctx.Doer,
log.NewColoredIDValue(issue.PosterID),
issueType,
ctx.Repo.Repository,
@@ -2108,7 +2108,7 @@ func NewComment(ctx *context.Context) {
return
}
- if issue.IsLocked && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) && !ctx.User.IsAdmin {
+ if issue.IsLocked && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) && !ctx.Doer.IsAdmin {
ctx.Flash.Error(ctx.Tr("repo.issues.comment_on_locked"))
ctx.Redirect(issue.HTMLURL(), http.StatusSeeOther)
return
@@ -2128,7 +2128,7 @@ func NewComment(ctx *context.Context) {
var comment *models.Comment
defer func() {
// Check if issue admin/poster changes the status of issue.
- if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) &&
+ if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.Doer.ID))) &&
(form.Status == "reopen" || form.Status == "close") &&
!(issue.IsPull && issue.PullRequest.HasMerged) {
@@ -2157,7 +2157,7 @@ func NewComment(ctx *context.Context) {
ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
} else {
isClosed := form.Status == "close"
- if err := issue_service.ChangeStatus(issue, ctx.User, isClosed); err != nil {
+ if err := issue_service.ChangeStatus(issue, ctx.Doer, isClosed); err != nil {
log.Error("ChangeStatus: %v", err)
if models.IsErrDependenciesLeft(err) {
@@ -2171,7 +2171,7 @@ func NewComment(ctx *context.Context) {
return
}
} else {
- if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
+ if err := stopTimerIfAvailable(ctx.Doer, issue); err != nil {
ctx.ServerError("CreateOrStopIssueStopwatch", err)
return
}
@@ -2198,7 +2198,7 @@ func NewComment(ctx *context.Context) {
return
}
- comment, err := comment_service.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments)
+ comment, err := comment_service.CreateIssueComment(ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments)
if err != nil {
ctx.ServerError("CreateIssueComment", err)
return
@@ -2220,7 +2220,7 @@ func UpdateCommentContent(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
+ if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
ctx.Error(http.StatusForbidden)
return
}
@@ -2238,7 +2238,7 @@ func UpdateCommentContent(ctx *context.Context) {
})
return
}
- if err = comment_service.UpdateComment(comment, ctx.User, oldContent); err != nil {
+ if err = comment_service.UpdateComment(comment, ctx.Doer, oldContent); err != nil {
ctx.ServerError("UpdateComment", err)
return
}
@@ -2286,7 +2286,7 @@ func DeleteComment(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
+ if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
ctx.Error(http.StatusForbidden)
return
} else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
@@ -2294,7 +2294,7 @@ func DeleteComment(ctx *context.Context) {
return
}
- if err = comment_service.DeleteComment(ctx.User, comment); err != nil {
+ if err = comment_service.DeleteComment(ctx.Doer, comment); err != nil {
ctx.ServerError("DeleteCommentByID", err)
return
}
@@ -2310,7 +2310,7 @@ func ChangeIssueReaction(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
+ if !ctx.IsSigned || (ctx.Doer.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
if log.IsTrace() {
if ctx.IsSigned {
issueType := "issues"
@@ -2319,7 +2319,7 @@ func ChangeIssueReaction(ctx *context.Context) {
}
log.Trace("Permission Denied: User %-v not the Poster (ID: %d) and cannot read %s in Repo %-v.\n"+
"User in Repo has Permissions: %-+v",
- ctx.User,
+ ctx.Doer,
log.NewColoredIDValue(issue.PosterID),
issueType,
ctx.Repo.Repository,
@@ -2340,7 +2340,7 @@ func ChangeIssueReaction(ctx *context.Context) {
switch ctx.Params(":action") {
case "react":
- reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
+ reaction, err := models.CreateIssueReaction(ctx.Doer, issue, form.Content)
if err != nil {
if models.IsErrForbiddenIssueReaction(err) {
ctx.ServerError("ChangeIssueReaction", err)
@@ -2358,7 +2358,7 @@ func ChangeIssueReaction(ctx *context.Context) {
log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
case "unreact":
- if err := models.DeleteIssueReaction(ctx.User, issue, form.Content); err != nil {
+ if err := models.DeleteIssueReaction(ctx.Doer, issue, form.Content); err != nil {
ctx.ServerError("DeleteIssueReaction", err)
return
}
@@ -2412,7 +2412,7 @@ func ChangeCommentReaction(ctx *context.Context) {
return
}
- if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull)) {
+ if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull)) {
if log.IsTrace() {
if ctx.IsSigned {
issueType := "issues"
@@ -2421,7 +2421,7 @@ func ChangeCommentReaction(ctx *context.Context) {
}
log.Trace("Permission Denied: User %-v not the Poster (ID: %d) and cannot read %s in Repo %-v.\n"+
"User in Repo has Permissions: %-+v",
- ctx.User,
+ ctx.Doer,
log.NewColoredIDValue(comment.Issue.PosterID),
issueType,
ctx.Repo.Repository,
@@ -2442,7 +2442,7 @@ func ChangeCommentReaction(ctx *context.Context) {
switch ctx.Params(":action") {
case "react":
- reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
+ reaction, err := models.CreateCommentReaction(ctx.Doer, comment.Issue, comment, form.Content)
if err != nil {
if models.IsErrForbiddenIssueReaction(err) {
ctx.ServerError("ChangeIssueReaction", err)
@@ -2460,7 +2460,7 @@ func ChangeCommentReaction(ctx *context.Context) {
log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID, reaction.ID)
case "unreact":
- if err := models.DeleteCommentReaction(ctx.User, comment.Issue, comment, form.Content); err != nil {
+ if err := models.DeleteCommentReaction(ctx.Doer, comment.Issue, comment, form.Content); err != nil {
ctx.ServerError("DeleteCommentReaction", err)
return
}
@@ -2520,7 +2520,7 @@ func filterXRefComments(ctx *context.Context, issue *models.Issue) error {
if err != nil {
return err
}
- perm, err := models.GetUserRepoPermission(c.RefRepo, ctx.User)
+ perm, err := models.GetUserRepoPermission(c.RefRepo, ctx.Doer)
if err != nil {
return err
}
@@ -2689,7 +2689,7 @@ func combineLabelComments(issue *models.Issue) {
// get all teams that current user can mention
func handleTeamMentions(ctx *context.Context) {
- if ctx.User == nil || !ctx.Repo.Owner.IsOrganization() {
+ if ctx.Doer == nil || !ctx.Repo.Owner.IsOrganization() {
return
}
@@ -2698,10 +2698,10 @@ func handleTeamMentions(ctx *context.Context) {
var teams []*models.Team
org := models.OrgFromUser(ctx.Repo.Owner)
// Admin has super access.
- if ctx.User.IsAdmin {
+ if ctx.Doer.IsAdmin {
isAdmin = true
} else {
- isAdmin, err = org.IsOwnedBy(ctx.User.ID)
+ isAdmin, err = org.IsOwnedBy(ctx.Doer.ID)
if err != nil {
ctx.ServerError("IsOwnedBy", err)
return
@@ -2715,7 +2715,7 @@ func handleTeamMentions(ctx *context.Context) {
return
}
} else {
- teams, err = org.GetUserTeams(ctx.User.ID)
+ teams, err = org.GetUserTeams(ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetUserTeams", err)
return