summaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/admin/hooks.go4
-rw-r--r--routers/web/admin/repos.go4
-rw-r--r--routers/web/admin/users.go2
-rw-r--r--routers/web/admin/users_test.go8
-rw-r--r--routers/web/auth/auth.go2
-rw-r--r--routers/web/auth/linkaccount.go2
-rw-r--r--routers/web/auth/oauth.go39
-rw-r--r--routers/web/auth/oauth_test.go7
-rw-r--r--routers/web/auth/openid.go6
-rw-r--r--routers/web/org/org_labels.go4
-rw-r--r--routers/web/org/setting.go6
-rw-r--r--routers/web/org/teams.go2
-rw-r--r--routers/web/repo/attachment.go4
-rw-r--r--routers/web/repo/commit.go2
-rw-r--r--routers/web/repo/compare.go2
-rw-r--r--routers/web/repo/issue.go64
-rw-r--r--routers/web/repo/issue_content_history.go4
-rw-r--r--routers/web/repo/issue_label.go10
-rw-r--r--routers/web/repo/issue_stopwatch.go2
-rw-r--r--routers/web/repo/projects.go32
-rw-r--r--routers/web/repo/pull.go12
-rw-r--r--routers/web/repo/pull_review.go4
-rw-r--r--routers/web/repo/release.go4
-rw-r--r--routers/web/repo/repo.go6
-rw-r--r--routers/web/repo/setting.go17
-rw-r--r--routers/web/repo/setting_protected_branch.go4
-rw-r--r--routers/web/repo/view.go6
-rw-r--r--routers/web/repo/webhook.go2
-rw-r--r--routers/web/user/avatar.go2
-rw-r--r--routers/web/user/home.go2
-rw-r--r--routers/web/user/notification.go8
-rw-r--r--routers/web/user/profile.go4
-rw-r--r--routers/web/user/setting/account.go2
-rw-r--r--routers/web/user/setting/adopt.go2
-rw-r--r--routers/web/user/setting/applications.go4
-rw-r--r--routers/web/user/setting/oauth2.go8
-rw-r--r--routers/web/user/setting/profile.go2
-rw-r--r--routers/web/user/setting/security/openid.go2
-rw-r--r--routers/web/webfinger.go4
39 files changed, 152 insertions, 149 deletions
diff --git a/routers/web/admin/hooks.go b/routers/web/admin/hooks.go
index 1483d0959d..bf71cb5595 100644
--- a/routers/web/admin/hooks.go
+++ b/routers/web/admin/hooks.go
@@ -35,7 +35,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
sys["Title"] = ctx.Tr("admin.systemhooks")
sys["Description"] = ctx.Tr("admin.systemhooks.desc")
- sys["Webhooks"], err = webhook.GetSystemWebhooks(util.OptionalBoolNone)
+ sys["Webhooks"], err = webhook.GetSystemWebhooks(ctx, util.OptionalBoolNone)
sys["BaseLink"] = setting.AppSubURL + "/admin/hooks"
sys["BaseLinkNew"] = setting.AppSubURL + "/admin/system-hooks"
if err != nil {
@@ -45,7 +45,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
def["Title"] = ctx.Tr("admin.defaulthooks")
def["Description"] = ctx.Tr("admin.defaulthooks.desc")
- def["Webhooks"], err = webhook.GetDefaultWebhooks()
+ def["Webhooks"], err = webhook.GetDefaultWebhooks(ctx)
def["BaseLink"] = setting.AppSubURL + "/admin/hooks"
def["BaseLinkNew"] = setting.AppSubURL + "/admin/default-hooks"
if err != nil {
diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go
index fb7be12c35..809d1de74b 100644
--- a/routers/web/admin/repos.go
+++ b/routers/web/admin/repos.go
@@ -121,7 +121,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
return
}
- ctxUser, err := user_model.GetUserByName(dirSplit[0])
+ ctxUser, err := user_model.GetUserByName(ctx, dirSplit[0])
if err != nil {
if user_model.IsErrUserNotExist(err) {
log.Debug("User does not exist: %s", dirSplit[0])
@@ -135,7 +135,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
repoName := dirSplit[1]
// check not a repo
- has, err := repo_model.IsRepositoryExist(ctxUser, repoName)
+ has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName)
if err != nil {
ctx.ServerError("IsRepositoryExist", err)
return
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 7841ac569f..c37ecfd71e 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -389,7 +389,7 @@ func EditUserPost(ctx *context.Context) {
u.ProhibitLogin = form.ProhibitLogin
}
- if err := user_model.UpdateUser(u, emailChanged); err != nil {
+ if err := user_model.UpdateUser(ctx, u, emailChanged); err != nil {
if user_model.IsErrEmailAlreadyUsed(err) {
ctx.Data["Err_Email"] = true
ctx.RenderWithErr(ctx.Tr("form.email_been_used"), tplUserEdit, &form)
diff --git a/routers/web/admin/users_test.go b/routers/web/admin/users_test.go
index 9de548685c..e63367ccf2 100644
--- a/routers/web/admin/users_test.go
+++ b/routers/web/admin/users_test.go
@@ -47,7 +47,7 @@ func TestNewUserPost_MustChangePassword(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
@@ -84,7 +84,7 @@ func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
@@ -151,7 +151,7 @@ func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
@@ -190,7 +190,7 @@ func TestNewUserPost_VisibilityPrivate(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go
index be936d2230..4d5a2c9335 100644
--- a/routers/web/auth/auth.go
+++ b/routers/web/auth/auth.go
@@ -64,7 +64,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
}
}()
- u, err := user_model.GetUserByName(uname)
+ u, err := user_model.GetUserByName(ctx, uname)
if err != nil {
if !user_model.IsErrUserNotExist(err) {
return false, fmt.Errorf("GetUserByName: %v", err)
diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go
index c3e96f077a..a2d76e9c5a 100644
--- a/routers/web/auth/linkaccount.go
+++ b/routers/web/auth/linkaccount.go
@@ -70,7 +70,7 @@ func LinkAccount(ctx *context.Context) {
ctx.Data["user_exists"] = true
}
} else if len(uname) != 0 {
- u, err := user_model.GetUserByName(uname)
+ u, err := user_model.GetUserByName(ctx, uname)
if err != nil && !user_model.IsErrUserNotExist(err) {
ctx.ServerError("UserSignIn", err)
return
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 4c3e3c3ace..9aa31c1c02 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -5,6 +5,7 @@
package auth
import (
+ stdContext "context"
"encoding/base64"
"errors"
"fmt"
@@ -135,9 +136,9 @@ type AccessTokenResponse struct {
IDToken string `json:"id_token,omitempty"`
}
-func newAccessTokenResponse(grant *auth.OAuth2Grant, serverKey, clientKey oauth2.JWTSigningKey) (*AccessTokenResponse, *AccessTokenError) {
+func newAccessTokenResponse(ctx stdContext.Context, grant *auth.OAuth2Grant, serverKey, clientKey oauth2.JWTSigningKey) (*AccessTokenResponse, *AccessTokenError) {
if setting.OAuth2.InvalidateRefreshTokens {
- if err := grant.IncreaseCounter(); err != nil {
+ if err := grant.IncreaseCounter(ctx); err != nil {
return nil, &AccessTokenError{
ErrorCode: AccessTokenErrorCodeInvalidGrant,
ErrorDescription: "cannot increase the grant counter",
@@ -182,7 +183,7 @@ func newAccessTokenResponse(grant *auth.OAuth2Grant, serverKey, clientKey oauth2
// generate OpenID Connect id_token
signedIDToken := ""
if grant.ScopeContains("openid") {
- app, err := auth.GetOAuth2ApplicationByID(grant.ApplicationID)
+ app, err := auth.GetOAuth2ApplicationByID(ctx, grant.ApplicationID)
if err != nil {
return nil, &AccessTokenError{
ErrorCode: AccessTokenErrorCodeInvalidRequest,
@@ -333,9 +334,9 @@ func IntrospectOAuth(ctx *context.Context) {
token, err := oauth2.ParseToken(form.Token, oauth2.DefaultSigningKey)
if err == nil {
if token.Valid() == nil {
- grant, err := auth.GetOAuth2GrantByID(token.GrantID)
+ grant, err := auth.GetOAuth2GrantByID(ctx, token.GrantID)
if err == nil && grant != nil {
- app, err := auth.GetOAuth2ApplicationByID(grant.ApplicationID)
+ app, err := auth.GetOAuth2ApplicationByID(ctx, grant.ApplicationID)
if err == nil && app != nil {
response.Active = true
response.Scope = grant.Scope
@@ -364,7 +365,7 @@ func AuthorizeOAuth(ctx *context.Context) {
return
}
- app, err := auth.GetOAuth2ApplicationByClientID(form.ClientID)
+ app, err := auth.GetOAuth2ApplicationByClientID(ctx, form.ClientID)
if err != nil {
if auth.IsErrOauthClientIDInvalid(err) {
handleAuthorizeError(ctx, AuthorizeError{
@@ -438,7 +439,7 @@ func AuthorizeOAuth(ctx *context.Context) {
return
}
- grant, err := app.GetGrantByUserID(ctx.Doer.ID)
+ grant, err := app.GetGrantByUserID(ctx, ctx.Doer.ID)
if err != nil {
handleServerError(ctx, form.State, form.RedirectURI)
return
@@ -446,7 +447,7 @@ func AuthorizeOAuth(ctx *context.Context) {
// Redirect if user already granted access
if grant != nil {
- code, err := grant.GenerateNewAuthorizationCode(form.RedirectURI, form.CodeChallenge, form.CodeChallengeMethod)
+ code, err := grant.GenerateNewAuthorizationCode(ctx, form.RedirectURI, form.CodeChallenge, form.CodeChallengeMethod)
if err != nil {
handleServerError(ctx, form.State, form.RedirectURI)
return
@@ -458,7 +459,7 @@ func AuthorizeOAuth(ctx *context.Context) {
}
// Update nonce to reflect the new session
if len(form.Nonce) > 0 {
- err := grant.SetNonce(form.Nonce)
+ err := grant.SetNonce(ctx, form.Nonce)
if err != nil {
log.Error("Unable to update nonce: %v", err)
}
@@ -510,12 +511,12 @@ func GrantApplicationOAuth(ctx *context.Context) {
ctx.Error(http.StatusBadRequest)
return
}
- app, err := auth.GetOAuth2ApplicationByClientID(form.ClientID)
+ app, err := auth.GetOAuth2ApplicationByClientID(ctx, form.ClientID)
if err != nil {
ctx.ServerError("GetOAuth2ApplicationByClientID", err)
return
}
- grant, err := app.CreateGrant(ctx.Doer.ID, form.Scope)
+ grant, err := app.CreateGrant(ctx, ctx.Doer.ID, form.Scope)
if err != nil {
handleAuthorizeError(ctx, AuthorizeError{
State: form.State,
@@ -525,7 +526,7 @@ func GrantApplicationOAuth(ctx *context.Context) {
return
}
if len(form.Nonce) > 0 {
- err := grant.SetNonce(form.Nonce)
+ err := grant.SetNonce(ctx, form.Nonce)
if err != nil {
log.Error("Unable to update nonce: %v", err)
}
@@ -535,7 +536,7 @@ func GrantApplicationOAuth(ctx *context.Context) {
codeChallenge, _ = ctx.Session.Get("CodeChallenge").(string)
codeChallengeMethod, _ = ctx.Session.Get("CodeChallengeMethod").(string)
- code, err := grant.GenerateNewAuthorizationCode(form.RedirectURI, codeChallenge, codeChallengeMethod)
+ code, err := grant.GenerateNewAuthorizationCode(ctx, form.RedirectURI, codeChallenge, codeChallengeMethod)
if err != nil {
handleServerError(ctx, form.State, form.RedirectURI)
return
@@ -648,7 +649,7 @@ func handleRefreshToken(ctx *context.Context, form forms.AccessTokenForm, server
return
}
// get grant before increasing counter
- grant, err := auth.GetOAuth2GrantByID(token.GrantID)
+ grant, err := auth.GetOAuth2GrantByID(ctx, token.GrantID)
if err != nil || grant == nil {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeInvalidGrant,
@@ -666,7 +667,7 @@ func handleRefreshToken(ctx *context.Context, form forms.AccessTokenForm, server
log.Warn("A client tried to use a refresh token for grant_id = %d was used twice!", grant.ID)
return
}
- accessToken, tokenErr := newAccessTokenResponse(grant, serverKey, clientKey)
+ accessToken, tokenErr := newAccessTokenResponse(ctx, grant, serverKey, clientKey)
if tokenErr != nil {
handleAccessTokenError(ctx, *tokenErr)
return
@@ -675,7 +676,7 @@ func handleRefreshToken(ctx *context.Context, form forms.AccessTokenForm, server
}
func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, serverKey, clientKey oauth2.JWTSigningKey) {
- app, err := auth.GetOAuth2ApplicationByClientID(form.ClientID)
+ app, err := auth.GetOAuth2ApplicationByClientID(ctx, form.ClientID)
if err != nil {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeInvalidClient,
@@ -697,7 +698,7 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
})
return
}
- authorizationCode, err := auth.GetOAuth2AuthorizationByCode(form.Code)
+ authorizationCode, err := auth.GetOAuth2AuthorizationByCode(ctx, form.Code)
if err != nil || authorizationCode == nil {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
@@ -722,13 +723,13 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
return
}
// remove token from database to deny duplicate usage
- if err := authorizationCode.Invalidate(); err != nil {
+ if err := authorizationCode.Invalidate(ctx); err != nil {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeInvalidRequest,
ErrorDescription: "cannot proceed your request",
})
}
- resp, tokenErr := newAccessTokenResponse(authorizationCode.Grant, serverKey, clientKey)
+ resp, tokenErr := newAccessTokenResponse(ctx, authorizationCode.Grant, serverKey, clientKey)
if tokenErr != nil {
handleAccessTokenError(ctx, *tokenErr)
return
diff --git a/routers/web/auth/oauth_test.go b/routers/web/auth/oauth_test.go
index 669d7431fc..5a09a95105 100644
--- a/routers/web/auth/oauth_test.go
+++ b/routers/web/auth/oauth_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"code.gitea.io/gitea/models/auth"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/services/auth/source/oauth2"
@@ -21,7 +22,7 @@ func createAndParseToken(t *testing.T, grant *auth.OAuth2Grant) *oauth2.OIDCToke
assert.NoError(t, err)
assert.NotNil(t, signingKey)
- response, terr := newAccessTokenResponse(grant, signingKey, signingKey)
+ response, terr := newAccessTokenResponse(db.DefaultContext, grant, signingKey, signingKey)
assert.Nil(t, terr)
assert.NotNil(t, response)
@@ -43,7 +44,7 @@ func createAndParseToken(t *testing.T, grant *auth.OAuth2Grant) *oauth2.OIDCToke
func TestNewAccessTokenResponse_OIDCToken(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- grants, err := auth.GetOAuth2GrantsByUserID(3)
+ grants, err := auth.GetOAuth2GrantsByUserID(db.DefaultContext, 3)
assert.NoError(t, err)
assert.Len(t, grants, 1)
@@ -59,7 +60,7 @@ func TestNewAccessTokenResponse_OIDCToken(t *testing.T) {
assert.False(t, oidcToken.EmailVerified)
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
- grants, err = auth.GetOAuth2GrantsByUserID(user.ID)
+ grants, err = auth.GetOAuth2GrantsByUserID(db.DefaultContext, user.ID)
assert.NoError(t, err)
assert.Len(t, grants, 1)
diff --git a/routers/web/auth/openid.go b/routers/web/auth/openid.go
index 3012d8c5a5..32ae91da47 100644
--- a/routers/web/auth/openid.go
+++ b/routers/web/auth/openid.go
@@ -217,7 +217,7 @@ func signInOpenIDVerify(ctx *context.Context) {
}
if u == nil && nickname != "" {
- u, _ = user_model.GetUserByName(nickname)
+ u, _ = user_model.GetUserByName(ctx, nickname)
if err != nil {
if !user_model.IsErrUserNotExist(err) {
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{
@@ -307,7 +307,7 @@ func ConnectOpenIDPost(ctx *context.Context) {
// add OpenID for the user
userOID := &user_model.UserOpenID{UID: u.ID, URI: oid}
- if err = user_model.AddUserOpenID(userOID); err != nil {
+ if err = user_model.AddUserOpenID(ctx, userOID); err != nil {
if user_model.IsErrOpenIDAlreadyUsed(err) {
ctx.RenderWithErr(ctx.Tr("form.openid_been_used", oid), tplConnectOID, &form)
return
@@ -434,7 +434,7 @@ func RegisterOpenIDPost(ctx *context.Context) {
// add OpenID for the user
userOID := &user_model.UserOpenID{UID: u.ID, URI: oid}
- if err = user_model.AddUserOpenID(userOID); err != nil {
+ if err = user_model.AddUserOpenID(ctx, userOID); err != nil {
if user_model.IsErrOpenIDAlreadyUsed(err) {
ctx.RenderWithErr(ctx.Tr("form.openid_been_used", oid), tplSignUpOID, &form)
return
diff --git a/routers/web/org/org_labels.go b/routers/web/org/org_labels.go
index d79ffc597c..bfa9f162c3 100644
--- a/routers/web/org/org_labels.go
+++ b/routers/web/org/org_labels.go
@@ -17,7 +17,7 @@ import (
// RetrieveLabels find all the labels of an organization
func RetrieveLabels(ctx *context.Context) {
- labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.FormString("sort"), db.ListOptions{})
+ labels, err := models.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), db.ListOptions{})
if err != nil {
ctx.ServerError("RetrieveLabels.GetLabels", err)
return
@@ -59,7 +59,7 @@ func NewLabel(ctx *context.Context) {
// UpdateLabel update a label's name and color
func UpdateLabel(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.CreateLabelForm)
- l, err := models.GetLabelInOrgByID(ctx.Org.Organization.ID, form.ID)
+ l, err := models.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, form.ID)
if err != nil {
switch {
case models.IsErrOrgLabelNotExist(err):
diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go
index 5cd245ef09..758ca47af6 100644
--- a/routers/web/org/setting.go
+++ b/routers/web/org/setting.go
@@ -66,7 +66,7 @@ func SettingsPost(ctx *context.Context) {
// Check if organization name has been changed.
if org.LowerName != strings.ToLower(form.Name) {
- isExist, err := user_model.IsUserExist(org.ID, form.Name)
+ isExist, err := user_model.IsUserExist(ctx, org.ID, form.Name)
if err != nil {
ctx.ServerError("IsUserExist", err)
return
@@ -110,7 +110,7 @@ func SettingsPost(ctx *context.Context) {
visibilityChanged := form.Visibility != org.Visibility
org.Visibility = form.Visibility
- if err := user_model.UpdateUser(org.AsUser(), false); err != nil {
+ if err := user_model.UpdateUser(ctx, org.AsUser(), false); err != nil {
ctx.ServerError("UpdateUser", err)
return
}
@@ -207,7 +207,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["BaseLinkNew"] = ctx.Org.OrgLink + "/settings/hooks"
ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc")
- ws, err := webhook.ListWebhooksByOpts(&webhook.ListWebhookOptions{OrgID: ctx.Org.Organization.ID})
+ ws, err := webhook.ListWebhooksByOpts(ctx, &webhook.ListWebhookOptions{OrgID: ctx.Org.Organization.ID})
if err != nil {
ctx.ServerError("GetWebhooksByOrgId", err)
return
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index 3689ffe93d..284fb096f3 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -122,7 +122,7 @@ func TeamsAction(ctx *context.Context) {
}
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname")))
var u *user_model.User
- u, err = user_model.GetUserByName(uname)
+ u, err = user_model.GetUserByName(ctx, uname)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go
index b05d6448d9..701236f838 100644
--- a/routers/web/repo/attachment.go
+++ b/routers/web/repo/attachment.go
@@ -64,7 +64,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) {
// DeleteAttachment response for deleting issue's attachment
func DeleteAttachment(ctx *context.Context) {
file := ctx.FormString("file")
- attach, err := repo_model.GetAttachmentByUUID(file)
+ attach, err := repo_model.GetAttachmentByUUID(ctx, file)
if err != nil {
ctx.Error(http.StatusBadRequest, err.Error())
return
@@ -85,7 +85,7 @@ func DeleteAttachment(ctx *context.Context) {
// GetAttachment serve attachements
func GetAttachment(ctx *context.Context) {
- attach, err := repo_model.GetAttachmentByUUID(ctx.Params(":uuid"))
+ attach, err := repo_model.GetAttachmentByUUID(ctx, ctx.Params(":uuid"))
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
ctx.Error(http.StatusNotFound)
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index 7f68fd3dd1..1636a6c293 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -335,7 +335,7 @@ func Diff(ctx *context.Context) {
ctx.Data["Commit"] = commit
ctx.Data["Diff"] = diff
- statuses, _, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, commitID, db.ListOptions{})
+ statuses, _, err := models.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, commitID, db.ListOptions{})
if err != nil {
log.Error("GetLatestCommitStatus: %v", err)
}
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 3ea888454c..9f94489235 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -254,7 +254,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
} else if len(headInfos) == 2 {
headInfosSplit := strings.Split(headInfos[0], "/")
if len(headInfosSplit) == 1 {
- ci.HeadUser, err = user_model.GetUserByName(headInfos[0])
+ ci.HeadUser, err = user_model.GetUserByName(ctx, headInfos[0])
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound("GetUserByName", nil)
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index f50b30da1c..079ccbf6cf 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -255,7 +255,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
issueList := models.IssueList(issues)
- approvalCounts, err := issueList.GetApprovalCounts()
+ approvalCounts, err := issueList.GetApprovalCounts(ctx)
if err != nil {
ctx.ServerError("ApprovalCounts", err)
return
@@ -294,14 +294,14 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
return
}
- labels, err := models.GetLabelsByRepoID(repo.ID, "", db.ListOptions{})
+ labels, err := models.GetLabelsByRepoID(ctx, repo.ID, "", db.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByRepoID", err)
return
}
if repo.Owner.IsOrganization() {
- orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
+ orgLabels, err := models.GetLabelsByOrgID(ctx, repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByOrgID", err)
return
@@ -343,7 +343,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
if ctx.Repo.CanWriteIssuesOrPulls(ctx.Params(":type") == "pulls") {
- projects, _, err := project_model.GetProjects(project_model.SearchOptions{
+ projects, _, err := project_model.GetProjects(ctx, project_model.SearchOptions{
RepoID: repo.ID,
Type: project_model.TypeRepository,
IsClosed: util.OptionalBoolOf(isShowClosed),
@@ -453,7 +453,7 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *repo_model.R
func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
var err error
- ctx.Data["OpenProjects"], _, err = project_model.GetProjects(project_model.SearchOptions{
+ ctx.Data["OpenProjects"], _, err = project_model.GetProjects(ctx, project_model.SearchOptions{
RepoID: repo.ID,
Page: -1,
IsClosed: util.OptionalBoolFalse,
@@ -464,7 +464,7 @@ func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
return
}
- ctx.Data["ClosedProjects"], _, err = project_model.GetProjects(project_model.SearchOptions{
+ ctx.Data["ClosedProjects"], _, err = project_model.GetProjects(ctx, project_model.SearchOptions{
RepoID: repo.ID,
Page: -1,
IsClosed: util.OptionalBoolTrue,
@@ -673,14 +673,14 @@ func RetrieveRepoMetas(ctx *context.Context, repo *repo_model.Repository, isPull
return nil
}
- labels, err := models.GetLabelsByRepoID(repo.ID, "", db.ListOptions{})
+ labels, err := models.GetLabelsByRepoID(ctx, repo.ID, "", db.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByRepoID", err)
return nil
}
ctx.Data["Labels"] = labels
if repo.Owner.IsOrganization() {
- orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
+ orgLabels, err := models.GetLabelsByOrgID(ctx, repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
if err != nil {
return nil
}
@@ -761,10 +761,10 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs,
ctx.Data[issueTemplateTitleKey] = meta.Title
ctx.Data[ctxDataKey] = templateBody
labelIDs := make([]string, 0, len(meta.Labels))
- if repoLabels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, "", db.ListOptions{}); err == nil {
+ if repoLabels, err := models.GetLabelsByRepoID(ctx, ctx.Repo.Repository.ID, "", db.ListOptions{}); err == nil {
ctx.Data["Labels"] = repoLabels
if ctx.Repo.Owner.IsOrganization() {
- if orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{}); err == nil {
+ if orgLabels, err := models.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{}); err == nil {
ctx.Data["OrgLabels"] = orgLabels
repoLabels = append(repoLabels, orgLabels...)
}
@@ -818,7 +818,7 @@ func NewIssue(ctx *context.Context) {
projectID := ctx.FormInt64("project")
if projectID > 0 {
- project, err := project_model.GetProjectByID(projectID)
+ project, err := project_model.GetProjectByID(ctx, projectID)
if err != nil {
log.Error("GetProjectByID: %d: %v", projectID, err)
} else if project.RepoID != ctx.Repo.Repository.ID {
@@ -930,7 +930,7 @@ func ValidateRepoMetas(ctx *context.Context, form forms.CreateIssueForm, isPull
}
if form.ProjectID > 0 {
- p, err := project_model.GetProjectByID(form.ProjectID)
+ p, err := project_model.GetProjectByID(ctx, form.ProjectID)
if err != nil {
ctx.ServerError("GetProjectByID", err)
return nil, nil, 0, 0
@@ -1237,7 +1237,7 @@ func ViewIssue(ctx *context.Context) {
for i := range issue.Labels {
labelIDMark[issue.Labels[i].ID] = true
}
- labels, err := models.GetLabelsByRepoID(repo.ID, "", db.ListOptions{})
+ labels, err := models.GetLabelsByRepoID(ctx, repo.ID, "", db.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByRepoID", err)
return
@@ -1245,7 +1245,7 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Labels"] = labels
if repo.Owner.IsOrganization() {
- orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
+ orgLabels, err := models.GetLabelsByOrgID(ctx, repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByOrgID", err)
return
@@ -1277,7 +1277,7 @@ func ViewIssue(ctx *context.Context) {
if issue.IsPull {
canChooseReviewer := ctx.Repo.CanWrite(unit.TypePullRequests)
if !canChooseReviewer && ctx.Doer != nil && ctx.IsSigned {
- canChooseReviewer, err = models.IsOfficialReviewer(issue, ctx.Doer)
+ canChooseReviewer, err = models.IsOfficialReviewer(ctx, issue, ctx.Doer)
if err != nil {
ctx.ServerError("IsOfficialReviewer", err)
return
@@ -1312,7 +1312,7 @@ func ViewIssue(ctx *context.Context) {
if !ctx.Data["IsStopwatchRunning"].(bool) {
var exists bool
var sw *models.Stopwatch
- if exists, sw, err = models.HasUserStopwatch(ctx.Doer.ID); err != nil {
+ if exists, sw, err = models.HasUserStopwatch(ctx, ctx.Doer.ID); err != nil {
ctx.ServerError("HasUserStopwatch", err)
return
}
@@ -1688,12 +1688,12 @@ func ViewIssue(ctx *context.Context) {
}
// Get Dependencies
- ctx.Data["BlockedByDependencies"], err = issue.BlockedByDependencies()
+ ctx.Data["BlockedByDependencies"], err = issue.BlockedByDependencies(ctx)
if err != nil {
ctx.ServerError("BlockedByDependencies", err)
return
}
- ctx.Data["BlockingDependencies"], err = issue.BlockingDependencies()
+ ctx.Data["BlockingDependencies"], err = issue.BlockingDependencies(ctx)
if err != nil {
ctx.ServerError("BlockingDependencies", err)
return
@@ -1767,7 +1767,7 @@ func getActionIssues(ctx *context.Context) []*models.Issue {
}
issueIDs = append(issueIDs, issueID)
}
- issues, err := models.GetIssuesByIDs(issueIDs)
+ issues, err := models.GetIssuesByIDs(ctx, issueIDs)
if err != nil {
ctx.ServerError("GetIssuesByIDs", err)
return nil
@@ -1873,7 +1873,7 @@ func UpdateIssueContent(ctx *context.Context) {
// when update the request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
if !ctx.FormBool("ignore_attachments") {
- if err := updateAttachments(issue, ctx.FormStrings("files[]")); err != nil {
+ if err := updateAttachments(ctx, issue, ctx.FormStrings("files[]")); err != nil {
ctx.ServerError("UpdateAttachments", err)
return
}
@@ -2047,7 +2047,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
return
}
- team, err := organization.GetTeamByID(-reviewID)
+ team, err := organization.GetTeamByID(ctx, -reviewID)
if err != nil {
ctx.ServerError("GetTeamByID", err)
return
@@ -2160,7 +2160,7 @@ func SearchIssues(ctx *context.Context) {
opts.AllLimited = true
}
if ctx.FormString("owner") != "" {
- owner, err := user_model.GetUserByName(ctx.FormString("owner"))
+ owner, err := user_model.GetUserByName(ctx, ctx.FormString("owner"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusBadRequest, "Owner not found", err.Error())
@@ -2179,7 +2179,7 @@ func SearchIssues(ctx *context.Context) {
ctx.Error(http.StatusBadRequest, "", "Owner organisation is required for filtering on team")
return
}
- team, err := organization.GetTeam(opts.OwnerID, ctx.FormString("team"))
+ team, err := organization.GetTeam(ctx, opts.OwnerID, ctx.FormString("team"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.Error(http.StatusBadRequest, "Team not found", err.Error())
@@ -2307,7 +2307,7 @@ func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
return 0
}
- user, err := user_model.GetUserByName(userName)
+ user, err := user_model.GetUserByName(ctx, userName)
if user_model.IsErrUserNotExist(err) {
ctx.NotFound("", err)
return 0
@@ -2631,7 +2631,7 @@ func NewComment(ctx *context.Context) {
// UpdateCommentContent change comment of issue's content
func UpdateCommentContent(ctx *context.Context) {
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
return
@@ -2672,7 +2672,7 @@ func UpdateCommentContent(ctx *context.Context) {
// when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
if !ctx.FormBool("ignore_attachments") {
- if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil {
+ if err := updateAttachments(ctx, comment, ctx.FormStrings("files[]")); err != nil {
ctx.ServerError("UpdateAttachments", err)
return
}
@@ -2697,7 +2697,7 @@ func UpdateCommentContent(ctx *context.Context) {
// DeleteComment delete comment of issue
func DeleteComment(ctx *context.Context) {
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
return
@@ -2823,7 +2823,7 @@ func ChangeIssueReaction(ctx *context.Context) {
// ChangeCommentReaction create a reaction for comment
func ChangeCommentReaction(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.ReactionForm)
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
return
@@ -2968,7 +2968,7 @@ func GetIssueAttachments(ctx *context.Context) {
// GetCommentAttachments returns attachments for the comment
func GetCommentAttachments(ctx *context.Context) {
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
return
@@ -2986,7 +2986,7 @@ func GetCommentAttachments(ctx *context.Context) {
ctx.JSON(http.StatusOK, attachments)
}
-func updateAttachments(item interface{}, files []string) error {
+func updateAttachments(ctx *context.Context, item interface{}, files []string) error {
var attachments []*repo_model.Attachment
switch content := item.(type) {
case *models.Issue:
@@ -3020,9 +3020,9 @@ func updateAttachments(item interface{}, files []string) error {
}
switch content := item.(type) {
case *models.Issue:
- content.Attachments, err = repo_model.GetAttachmentsByIssueID(content.ID)
+ content.Attachments, err = repo_model.GetAttachmentsByIssueID(ctx, content.ID)
case *models.Comment:
- content.Attachments, err = repo_model.GetAttachmentsByCommentID(content.ID)
+ content.Attachments, err = repo_model.GetAttachmentsByCommentID(ctx, content.ID)
default:
return fmt.Errorf("unknown Type: %T", content)
}
diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go
index 11cc8a2a6f..407832dffe 100644
--- a/routers/web/repo/issue_content_history.go
+++ b/routers/web/repo/issue_content_history.go
@@ -130,7 +130,7 @@ func GetContentHistoryDetail(ctx *context.Context) {
var comment *models.Comment
if history.CommentID != 0 {
var err error
- if comment, err = models.GetCommentByID(history.CommentID); err != nil {
+ if comment, err = models.GetCommentByID(ctx, history.CommentID); err != nil {
log.Error("can not get comment for issue content history %v. err=%v", historyID, err)
return
}
@@ -190,7 +190,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
var history *issuesModel.ContentHistory
var err error
if commentID != 0 {
- if comment, err = models.GetCommentByID(commentID); err != nil {
+ if comment, err = models.GetCommentByID(ctx, commentID); err != nil {
log.Error("can not get comment for issue content history %v. err=%v", historyID, err)
return
}
diff --git a/routers/web/repo/issue_label.go b/routers/web/repo/issue_label.go
index 887bbc115f..2e72d659be 100644
--- a/routers/web/repo/issue_label.go
+++ b/routers/web/repo/issue_label.go
@@ -56,7 +56,7 @@ func InitializeLabels(ctx *context.Context) {
// RetrieveLabels find all the labels of a repository and organization
func RetrieveLabels(ctx *context.Context) {
- labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.FormString("sort"), db.ListOptions{})
+ labels, err := models.GetLabelsByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormString("sort"), db.ListOptions{})
if err != nil {
ctx.ServerError("RetrieveLabels.GetLabels", err)
return
@@ -69,7 +69,7 @@ func RetrieveLabels(ctx *context.Context) {
ctx.Data["Labels"] = labels
if ctx.Repo.Owner.IsOrganization() {
- orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
+ orgLabels, err := models.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByOrgID", err)
return
@@ -127,7 +127,7 @@ func NewLabel(ctx *context.Context) {
// UpdateLabel update a label's name and color
func UpdateLabel(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.CreateLabelForm)
- l, err := models.GetLabelInRepoByID(ctx.Repo.Repository.ID, form.ID)
+ l, err := models.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, form.ID)
if err != nil {
switch {
case models.IsErrRepoLabelNotExist(err):
@@ -177,7 +177,7 @@ func UpdateIssueLabel(ctx *context.Context) {
}
}
case "attach", "detach", "toggle":
- label, err := models.GetLabelByID(ctx.FormInt64("id"))
+ label, err := models.GetLabelByID(ctx, ctx.FormInt64("id"))
if err != nil {
if models.IsErrRepoLabelNotExist(err) {
ctx.Error(http.StatusNotFound, "GetLabelByID")
@@ -191,7 +191,7 @@ func UpdateIssueLabel(ctx *context.Context) {
// detach if any issues already have label, otherwise attach
action = "attach"
for _, issue := range issues {
- if models.HasIssueLabel(issue.ID, label.ID) {
+ if models.HasIssueLabel(ctx, issue.ID, label.ID) {
action = "detach"
break
}
diff --git a/routers/web/repo/issue_stopwatch.go b/routers/web/repo/issue_stopwatch.go
index 83e4ecedbf..4e1f6af039 100644
--- a/routers/web/repo/issue_stopwatch.go
+++ b/routers/web/repo/issue_stopwatch.go
@@ -87,7 +87,7 @@ func GetActiveStopwatch(ctx *context.Context) {
return
}
- _, sw, err := models.HasUserStopwatch(ctx.Doer.ID)
+ _, sw, err := models.HasUserStopwatch(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("HasUserStopwatch", err)
return
diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go
index a6f843d848..c1805944db 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -70,7 +70,7 @@ func Projects(ctx *context.Context) {
total = repo.NumClosedProjects
}
- projects, count, err := project_model.GetProjects(project_model.SearchOptions{
+ projects, count, err := project_model.GetProjects(ctx, project_model.SearchOptions{
RepoID: repo.ID,
Page: page,
IsClosed: util.OptionalBoolOf(isShowClosed),
@@ -182,7 +182,7 @@ func ChangeProjectStatus(ctx *context.Context) {
// DeleteProject delete a project
func DeleteProject(ctx *context.Context) {
- p, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -213,7 +213,7 @@ func EditProject(ctx *context.Context) {
ctx.Data["PageIsEditProjects"] = true
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
- p, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -245,7 +245,7 @@ func EditProjectPost(ctx *context.Context) {
return
}
- p, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -261,7 +261,7 @@ func EditProjectPost(ctx *context.Context) {
p.Title = form.Title
p.Description = form.Content
- if err = project_model.UpdateProject(p); err != nil {
+ if err = project_model.UpdateProject(ctx, p); err != nil {
ctx.ServerError("UpdateProjects", err)
return
}
@@ -272,7 +272,7 @@ func EditProjectPost(ctx *context.Context) {
// ViewProject renders the project board for a project
func ViewProject(ctx *context.Context) {
- project, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -286,7 +286,7 @@ func ViewProject(ctx *context.Context) {
return
}
- boards, err := project_model.GetBoards(project.ID)
+ boards, err := project_model.GetBoards(ctx, project.ID)
if err != nil {
ctx.ServerError("GetProjectBoards", err)
return
@@ -385,7 +385,7 @@ func DeleteProjectBoard(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -395,7 +395,7 @@ func DeleteProjectBoard(ctx *context.Context) {
return
}
- pb, err := project_model.GetBoard(ctx.ParamsInt64(":boardID"))
+ pb, err := project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
return
@@ -434,7 +434,7 @@ func AddBoardToProjectPost(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -474,7 +474,7 @@ func checkProjectBoardChangePermissions(ctx *context.Context) (*project_model.Pr
return nil, nil
}
- project, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -484,7 +484,7 @@ func checkProjectBoardChangePermissions(ctx *context.Context) (*project_model.Pr
return nil, nil
}
- board, err := project_model.GetBoard(ctx.ParamsInt64(":boardID"))
+ board, err := project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
return nil, nil
@@ -523,7 +523,7 @@ func EditProjectBoard(ctx *context.Context) {
board.Sorting = form.Sorting
}
- if err := project_model.UpdateBoard(board); err != nil {
+ if err := project_model.UpdateBoard(ctx, board); err != nil {
ctx.ServerError("UpdateProjectBoard", err)
return
}
@@ -566,7 +566,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("ProjectNotExist", nil)
@@ -589,7 +589,7 @@ func MoveIssues(ctx *context.Context) {
Title: ctx.Tr("repo.projects.type.uncategorized"),
}
} else {
- board, err = project_model.GetBoard(ctx.ParamsInt64(":boardID"))
+ board, err = project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
if project_model.IsErrProjectBoardNotExist(err) {
ctx.NotFound("ProjectBoardNotExist", nil)
@@ -622,7 +622,7 @@ func MoveIssues(ctx *context.Context) {
issueIDs = append(issueIDs, issue.IssueID)
sortedIssueIDs[issue.Sorting] = issue.IssueID
}
- movedIssues, err := models.GetIssuesByIDs(issueIDs)
+ movedIssues, err := models.GetIssuesByIDs(ctx, issueIDs)
if err != nil {
if models.IsErrIssueNotExist(err) {
ctx.NotFound("IssueNotExisting", nil)
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index fd224a22ef..3f24be33d6 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -377,7 +377,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C
if len(compareInfo.Commits) != 0 {
sha := compareInfo.Commits[0].ID.String()
- commitStatuses, _, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, sha, db.ListOptions{})
+ commitStatuses, _, err := models.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, sha, db.ListOptions{})
if err != nil {
ctx.ServerError("GetLatestCommitStatus", err)
return nil
@@ -438,7 +438,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err)
return nil
}
- commitStatuses, _, err := models.GetLatestCommitStatus(repo.ID, sha, db.ListOptions{})
+ commitStatuses, _, err := models.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{})
if err != nil {
ctx.ServerError("GetLatestCommitStatus", err)
return nil
@@ -528,7 +528,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
return nil
}
- commitStatuses, _, err := models.GetLatestCommitStatus(repo.ID, sha, db.ListOptions{})
+ commitStatuses, _, err := models.GetLatestCommitStatus(ctx, repo.ID, sha, db.ListOptions{})
if err != nil {
ctx.ServerError("GetLatestCommitStatus", err)
return nil
@@ -767,7 +767,7 @@ func ViewPullFiles(ctx *context.Context) {
return
}
- currentReview, err := models.GetCurrentReview(ctx.Doer, issue)
+ currentReview, err := models.GetCurrentReview(ctx, ctx.Doer, issue)
if err != nil && !models.IsErrReviewNotExist(err) {
ctx.ServerError("GetCurrentReview", err)
return
@@ -1354,7 +1354,7 @@ func DownloadPullPatch(ctx *context.Context) {
// DownloadPullDiffOrPatch render a pull's raw diff or patch
func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -1447,7 +1447,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
func SetAllowEdits(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.UpdateAllowEditsForm)
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go
index 98272ed48d..e051290200 100644
--- a/routers/web/repo/pull_review.go
+++ b/routers/web/repo/pull_review.go
@@ -31,7 +31,7 @@ func RenderNewCodeCommentForm(ctx *context.Context) {
if !issue.IsPull {
return
}
- currentReview, err := models.GetCurrentReview(ctx.Doer, issue)
+ currentReview, err := models.GetCurrentReview(ctx, ctx.Doer, issue)
if err != nil && !models.IsErrReviewNotExist(err) {
ctx.ServerError("GetCurrentReview", err)
return
@@ -107,7 +107,7 @@ func UpdateResolveConversation(ctx *context.Context) {
action := ctx.FormString("action")
commentID := ctx.FormInt64("comment_id")
- comment, err := models.GetCommentByID(commentID)
+ comment, err := models.GetCommentByID(ctx, commentID)
if err != nil {
ctx.ServerError("GetIssueByID", err)
return
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index ebc6500802..fba3ef7a06 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -126,7 +126,7 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
return
}
- if err = models.GetReleaseAttachments(releases...); err != nil {
+ if err = models.GetReleaseAttachments(ctx, releases...); err != nil {
ctx.ServerError("GetReleaseAttachments", err)
return
}
@@ -202,7 +202,7 @@ func SingleRelease(ctx *context.Context) {
return
}
- err = models.GetReleaseAttachments(release)
+ err = models.GetReleaseAttachments(ctx, release)
if err != nil {
ctx.ServerError("GetReleaseAttachments", err)
return
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 199651b2f1..30cb888dce 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -285,9 +285,9 @@ func Action(ctx *context.Context) {
var err error
switch ctx.Params(":action") {
case "watch":
- err = repo_model.WatchRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true)
+ err = repo_model.WatchRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, true)
case "unwatch":
- err = repo_model.WatchRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, false)
+ err = repo_model.WatchRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, false)
case "star":
err = repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true)
case "unstar":
@@ -369,7 +369,7 @@ func RedirectDownload(ctx *context.Context) {
}
if len(releases) == 1 {
release := releases[0]
- att, err := repo_model.GetAttachmentByReleaseIDFileName(release.ID, fileName)
+ att, err := repo_model.GetAttachmentByReleaseIDFileName(ctx, release.ID, fileName)
if err != nil {
ctx.Error(http.StatusNotFound)
return
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index dd1cb412c1..a60bf52622 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -72,14 +72,14 @@ func Settings(ctx *context.Context) {
ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
if ctx.Doer.IsAdmin {
if setting.Indexer.RepoIndexerEnabled {
- status, err := repo_model.GetIndexerStatus(ctx.Repo.Repository, repo_model.RepoIndexerTypeCode)
+ status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeCode)
if err != nil {
ctx.ServerError("repo.indexer_status", err)
return
}
ctx.Data["CodeIndexerStatus"] = status
}
- status, err := repo_model.GetIndexerStatus(ctx.Repo.Repository, repo_model.RepoIndexerTypeStats)
+ status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeStats)
if err != nil {
ctx.ServerError("repo.indexer_status", err)
return
@@ -195,7 +195,7 @@ func SettingsPost(ctx *context.Context) {
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
ctx.Repo.Mirror.Interval = interval
ctx.Repo.Mirror.ScheduleNextUpdate()
- if err := repo_model.UpdateMirror(ctx.Repo.Mirror); err != nil {
+ if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil {
ctx.Data["Err_Interval"] = true
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
return
@@ -241,7 +241,7 @@ func SettingsPost(ctx *context.Context) {
ctx.Repo.Mirror.LFS = form.LFS
ctx.Repo.Mirror.LFSEndpoint = form.LFSEndpoint
- if err := repo_model.UpdateMirror(ctx.Repo.Mirror); err != nil {
+ if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil {
ctx.ServerError("UpdateMirror", err)
return
}
@@ -642,7 +642,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- newOwner, err := user_model.GetUserByName(ctx.FormString("new_owner_name"))
+ newOwner, err := user_model.GetUserByName(ctx, ctx.FormString("new_owner_name"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), tplSettingsOptions, nil)
@@ -840,7 +840,7 @@ func Collaboration(ctx *context.Context) {
}
ctx.Data["Collaborators"] = users
- teams, err := organization.GetRepoTeams(ctx.Repo.Repository)
+ teams, err := organization.GetRepoTeams(ctx, ctx.Repo.Repository)
if err != nil {
ctx.ServerError("GetRepoTeams", err)
return
@@ -863,7 +863,7 @@ func CollaborationPost(ctx *context.Context) {
return
}
- u, err := user_model.GetUserByName(name)
+ u, err := user_model.GetUserByName(ctx, name)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
@@ -983,7 +983,7 @@ func DeleteTeam(ctx *context.Context) {
return
}
- team, err := organization.GetTeamByID(ctx.FormInt64("id"))
+ team, err := organization.GetTeamByID(ctx, ctx.FormInt64("id"))
if err != nil {
ctx.ServerError("GetTeamByID", err)
return
@@ -1215,6 +1215,7 @@ func selectPushMirrorByForm(form *forms.RepoSettingForm, repo *repo_model.Reposi
for _, m := range pushMirrors {
if m.ID == id {
+ m.Repo = repo
return m, nil
}
}
diff --git a/routers/web/repo/setting_protected_branch.go b/routers/web/repo/setting_protected_branch.go
index 35f35163cb..6c2f3ce01d 100644
--- a/routers/web/repo/setting_protected_branch.go
+++ b/routers/web/repo/setting_protected_branch.go
@@ -111,7 +111,7 @@ func SettingsProtectedBranch(c *context.Context) {
c.Data["Title"] = c.Tr("repo.settings.protected_branch") + " - " + branch
c.Data["PageIsSettingsBranches"] = true
- protectBranch, err := models.GetProtectedBranchBy(c.Repo.Repository.ID, branch)
+ protectBranch, err := models.GetProtectedBranchBy(c, c.Repo.Repository.ID, branch)
if err != nil {
if !git.IsErrBranchNotExist(err) {
c.ServerError("GetProtectBranchOfRepoByName", err)
@@ -184,7 +184,7 @@ func SettingsProtectedBranchPost(ctx *context.Context) {
return
}
- protectBranch, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branch)
+ protectBranch, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branch)
if err != nil {
if !git.IsErrBranchNotExist(err) {
ctx.ServerError("GetProtectBranchOfRepoByName", err)
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 86fc36fad7..95ca81c442 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -684,7 +684,7 @@ func checkHomeCodeViewable(ctx *context.Context) {
if ctx.IsSigned {
// Set repo notification-status read if unread
- if err := models.SetRepoReadBy(ctx.Repo.Repository.ID, ctx.Doer.ID); err != nil {
+ if err := models.SetRepoReadBy(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID); err != nil {
ctx.ServerError("ReadBy", err)
return
}
@@ -839,7 +839,7 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri
ctx.Data["LatestCommitUser"] = user_model.ValidateCommitWithEmail(latestCommit)
}
- statuses, _, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), db.ListOptions{})
+ statuses, _, err := models.GetLatestCommitStatus(ctx, ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), db.ListOptions{})
if err != nil {
log.Error("GetLatestCommitStatus: %v", err)
}
@@ -901,7 +901,7 @@ func renderCode(ctx *context.Context) {
// it's possible for a repository to be non-empty by that flag but still 500
// because there are no branches - only tags -or the default branch is non-extant as it has been 0-pushed.
ctx.Repo.Repository.IsEmpty = false
- if err = repo_model.UpdateRepositoryCols(ctx.Repo.Repository, "is_empty"); err != nil {
+ if err = repo_model.UpdateRepositoryCols(ctx, ctx.Repo.Repository, "is_empty"); err != nil {
ctx.ServerError("UpdateRepositoryCols", err)
return
}
diff --git a/routers/web/repo/webhook.go b/routers/web/repo/webhook.go
index d2e2461189..a9b14ee21f 100644
--- a/routers/web/repo/webhook.go
+++ b/routers/web/repo/webhook.go
@@ -44,7 +44,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["BaseLinkNew"] = ctx.Repo.RepoLink + "/settings/hooks"
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.io/en-us/webhooks/")
- ws, err := webhook.ListWebhooksByOpts(&webhook.ListWebhookOptions{RepoID: ctx.Repo.Repository.ID})
+ ws, err := webhook.ListWebhooksByOpts(ctx, &webhook.ListWebhookOptions{RepoID: ctx.Repo.Repository.ID})
if err != nil {
ctx.ServerError("GetWebhooksByRepoID", err)
return
diff --git a/routers/web/user/avatar.go b/routers/web/user/avatar.go
index c8bca9dc2c..53a603fab0 100644
--- a/routers/web/user/avatar.go
+++ b/routers/web/user/avatar.go
@@ -30,7 +30,7 @@ func AvatarByUserName(ctx *context.Context) {
var user *user_model.User
if strings.ToLower(userName) != "ghost" {
var err error
- if user, err = user_model.GetUserByName(userName); err != nil {
+ if user, err = user_model.GetUserByName(ctx, userName); err != nil {
ctx.ServerError("Invalid user: "+userName, err)
return
}
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 37f6b88352..2a802053fb 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -615,7 +615,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
ctx.Data["Issues"] = issues
- approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
+ approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx)
if err != nil {
ctx.ServerError("ApprovalCounts", err)
return
diff --git a/routers/web/user/notification.go b/routers/web/user/notification.go
index 05421cf555..0b1789dcf8 100644
--- a/routers/web/user/notification.go
+++ b/routers/web/user/notification.go
@@ -34,7 +34,7 @@ func GetNotificationCount(c *context.Context) {
}
c.Data["NotificationUnreadCount"] = func() int64 {
- count, err := models.GetNotificationCount(c.Doer, models.NotificationStatusUnread)
+ count, err := models.GetNotificationCount(c, c.Doer, models.NotificationStatusUnread)
if err != nil {
c.ServerError("GetNotificationCount", err)
return -1
@@ -79,7 +79,7 @@ func getNotifications(c *context.Context) {
status = models.NotificationStatusUnread
}
- total, err := models.GetNotificationCount(c.Doer, status)
+ total, err := models.GetNotificationCount(c, c.Doer, status)
if err != nil {
c.ServerError("ErrGetNotificationCount", err)
return
@@ -93,7 +93,7 @@ func getNotifications(c *context.Context) {
}
statuses := []models.NotificationStatus{status, models.NotificationStatusPinned}
- notifications, err := models.NotificationsForUser(c.Doer, statuses, page, perPage)
+ notifications, err := models.NotificationsForUser(c, c.Doer, statuses, page, perPage)
if err != nil {
c.ServerError("ErrNotificationsForUser", err)
return
@@ -195,5 +195,5 @@ func NotificationPurgePost(c *context.Context) {
// NewAvailable returns the notification counts
func NewAvailable(ctx *context.Context) {
- ctx.JSON(http.StatusOK, structs.NotificationCount{New: models.CountUnread(ctx.Doer)})
+ ctx.JSON(http.StatusOK, structs.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
}
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 85870eddf5..8bce5460cc 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -42,7 +42,7 @@ func Profile(ctx *context.Context) {
}
// check view permissions
- if !user_model.IsUserVisibleToViewer(ctx.ContextUser, ctx.Doer) {
+ if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
return
}
@@ -217,7 +217,7 @@ func Profile(ctx *context.Context) {
total = int(count)
case "projects":
- ctx.Data["OpenProjects"], _, err = project_model.GetProjects(project_model.SearchOptions{
+ ctx.Data["OpenProjects"], _, err = project_model.GetProjects(ctx, project_model.SearchOptions{
Page: -1,
IsClosed: util.OptionalBoolFalse,
Type: project_model.TypeIndividual,
diff --git a/routers/web/user/setting/account.go b/routers/web/user/setting/account.go
index b2476dff94..92f6c9a183 100644
--- a/routers/web/user/setting/account.go
+++ b/routers/web/user/setting/account.go
@@ -181,7 +181,7 @@ func EmailPost(ctx *context.Context) {
Email: form.Email,
IsActivated: !setting.Service.RegisterEmailConfirm,
}
- if err := user_model.AddEmailAddress(email); err != nil {
+ if err := user_model.AddEmailAddress(ctx, email); err != nil {
if user_model.IsErrEmailAlreadyUsed(err) {
loadAccountData(ctx)
diff --git a/routers/web/user/setting/adopt.go b/routers/web/user/setting/adopt.go
index ce2377a997..c7139f8bb1 100644
--- a/routers/web/user/setting/adopt.go
+++ b/routers/web/user/setting/adopt.go
@@ -32,7 +32,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
root := user_model.UserPath(ctxUser.LowerName)
// check not a repo
- has, err := repo_model.IsRepositoryExist(ctxUser, dir)
+ has, err := repo_model.IsRepositoryExist(ctx, ctxUser, dir)
if err != nil {
ctx.ServerError("IsRepositoryExist", err)
return
diff --git a/routers/web/user/setting/applications.go b/routers/web/user/setting/applications.go
index b0f599fc45..4ffec47801 100644
--- a/routers/web/user/setting/applications.go
+++ b/routers/web/user/setting/applications.go
@@ -93,12 +93,12 @@ func loadApplicationsData(ctx *context.Context) {
ctx.Data["Tokens"] = tokens
ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable
if setting.OAuth2.Enable {
- ctx.Data["Applications"], err = auth.GetOAuth2ApplicationsByUserID(ctx.Doer.ID)
+ ctx.Data["Applications"], err = auth.GetOAuth2ApplicationsByUserID(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetOAuth2ApplicationsByUserID", err)
return
}
- ctx.Data["Grants"], err = auth.GetOAuth2GrantsByUserID(ctx.Doer.ID)
+ ctx.Data["Grants"], err = auth.GetOAuth2GrantsByUserID(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetOAuth2GrantsByUserID", err)
return
diff --git a/routers/web/user/setting/oauth2.go b/routers/web/user/setting/oauth2.go
index 76c50852a0..db76a12f18 100644
--- a/routers/web/user/setting/oauth2.go
+++ b/routers/web/user/setting/oauth2.go
@@ -34,7 +34,7 @@ func OAuthApplicationsPost(ctx *context.Context) {
return
}
// TODO validate redirect URI
- app, err := auth.CreateOAuth2Application(auth.CreateOAuth2ApplicationOptions{
+ app, err := auth.CreateOAuth2Application(ctx, auth.CreateOAuth2ApplicationOptions{
Name: form.Name,
RedirectURIs: []string{form.RedirectURI},
UserID: ctx.Doer.ID,
@@ -85,7 +85,7 @@ func OAuthApplicationsRegenerateSecret(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsApplications"] = true
- app, err := auth.GetOAuth2ApplicationByID(ctx.ParamsInt64("id"))
+ app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.ParamsInt64("id"))
if err != nil {
if auth.IsErrOAuthApplicationNotFound(err) {
ctx.NotFound("Application not found", err)
@@ -110,7 +110,7 @@ func OAuthApplicationsRegenerateSecret(ctx *context.Context) {
// OAuth2ApplicationShow displays the given application
func OAuth2ApplicationShow(ctx *context.Context) {
- app, err := auth.GetOAuth2ApplicationByID(ctx.ParamsInt64("id"))
+ app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.ParamsInt64("id"))
if err != nil {
if auth.IsErrOAuthApplicationNotFound(err) {
ctx.NotFound("Application not found", err)
@@ -147,7 +147,7 @@ func RevokeOAuth2Grant(ctx *context.Context) {
ctx.ServerError("RevokeOAuth2Grant", fmt.Errorf("user id or grant id is zero"))
return
}
- if err := auth.RevokeOAuth2Grant(ctx.FormInt64("id"), ctx.Doer.ID); err != nil {
+ if err := auth.RevokeOAuth2Grant(ctx, ctx.FormInt64("id"), ctx.Doer.ID); err != nil {
ctx.ServerError("RevokeOAuth2Grant", err)
return
}
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index 0123b9b523..c2a406b184 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -180,7 +180,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *
} else if ctxUser.UseCustomAvatar && ctxUser.Avatar == "" {
// No avatar is uploaded but setting has been changed to enable,
// generate a random one when needed.
- if err := user_model.GenerateRandomAvatar(ctxUser); err != nil {
+ if err := user_model.GenerateRandomAvatar(ctx, ctxUser); err != nil {
log.Error("GenerateRandomAvatar[%d]: %v", ctxUser.ID, err)
}
}
diff --git a/routers/web/user/setting/security/openid.go b/routers/web/user/setting/security/openid.go
index 2ecc9b0533..a378c8bf64 100644
--- a/routers/web/user/setting/security/openid.go
+++ b/routers/web/user/setting/security/openid.go
@@ -90,7 +90,7 @@ func settingsOpenIDVerify(ctx *context.Context) {
log.Trace("Verified ID: " + id)
oid := &user_model.UserOpenID{UID: ctx.Doer.ID, URI: id}
- if err = user_model.AddUserOpenID(oid); err != nil {
+ if err = user_model.AddUserOpenID(ctx, oid); err != nil {
if user_model.IsErrOpenIDAlreadyUsed(err) {
ctx.RenderWithErr(ctx.Tr("form.openid_been_used", id), tplSettingsSecurity, &forms.AddOpenIDForm{Openid: id})
return
diff --git a/routers/web/webfinger.go b/routers/web/webfinger.go
index 27d0351b81..8402967867 100644
--- a/routers/web/webfinger.go
+++ b/routers/web/webfinger.go
@@ -59,7 +59,7 @@ func WebfingerQuery(ctx *context.Context) {
return
}
- u, err = user_model.GetUserByNameCtx(ctx, parts[0])
+ u, err = user_model.GetUserByName(ctx, parts[0])
case "mailto":
u, err = user_model.GetUserByEmailContext(ctx, resource.Opaque)
if u != nil && u.KeepEmailPrivate {
@@ -79,7 +79,7 @@ func WebfingerQuery(ctx *context.Context) {
return
}
- if !user_model.IsUserVisibleToViewer(u, ctx.Doer) {
+ if !user_model.IsUserVisibleToViewer(ctx, u, ctx.Doer) {
ctx.Error(http.StatusNotFound)
return
}