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