aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/admin/user.go2
-rw-r--r--routers/api/v1/api.go5
-rw-r--r--routers/api/v1/org/avatar.go4
-rw-r--r--routers/api/v1/org/team.go2
-rw-r--r--routers/api/v1/repo/issue.go4
-rw-r--r--routers/api/v1/repo/issue_dependency.go4
-rw-r--r--routers/api/v1/repo/key.go4
-rw-r--r--routers/api/v1/repo/milestone.go2
-rw-r--r--routers/api/v1/repo/pull.go4
-rw-r--r--routers/api/v1/user/avatar.go4
-rw-r--r--routers/api/v1/user/key.go14
11 files changed, 25 insertions, 24 deletions
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index 610eba1749..09d7c1a940 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -36,7 +36,7 @@ func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64
return
}
- source, err := auth.GetSourceByID(sourceID)
+ source, err := auth.GetSourceByID(ctx, sourceID)
if err != nil {
if auth.IsErrSourceNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 441801885f..8abe51ea4f 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -70,6 +70,7 @@ import (
actions_model "code.gitea.io/gitea/models/actions"
auth_model "code.gitea.io/gitea/models/auth"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
@@ -165,7 +166,7 @@ func repoAssignment() func(ctx *context.APIContext) {
ctx.ContextUser = owner
// Get repository.
- repo, err := repo_model.GetRepositoryByName(owner.ID, repoName)
+ repo, err := repo_model.GetRepositoryByName(ctx, owner.ID, repoName)
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
redirectRepoID, err := repo_model.LookupRedirect(owner.ID, repoName)
@@ -716,7 +717,7 @@ func buildAuthGroup() *auth.Group {
group.Add(&auth.ReverseProxy{})
}
- if setting.IsWindows && auth_model.IsSSPIEnabled() {
+ if setting.IsWindows && auth_model.IsSSPIEnabled(db.DefaultContext) {
group.Add(&auth.SSPI{}) // it MUST be the last, see the comment of SSPI
}
diff --git a/routers/api/v1/org/avatar.go b/routers/api/v1/org/avatar.go
index a7b5008525..7b621a50c3 100644
--- a/routers/api/v1/org/avatar.go
+++ b/routers/api/v1/org/avatar.go
@@ -43,7 +43,7 @@ func UpdateAvatar(ctx *context.APIContext) {
return
}
- err = user_service.UploadAvatar(ctx.Org.Organization.AsUser(), content)
+ err = user_service.UploadAvatar(ctx, ctx.Org.Organization.AsUser(), content)
if err != nil {
ctx.Error(http.StatusInternalServerError, "UploadAvatar", err)
}
@@ -69,7 +69,7 @@ func DeleteAvatar(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
- err := user_service.DeleteAvatar(ctx.Org.Organization.AsUser())
+ err := user_service.DeleteAvatar(ctx, ctx.Org.Organization.AsUser())
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAvatar", err)
}
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 9b68253623..f129c66230 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -638,7 +638,7 @@ func GetTeamRepo(ctx *context.APIContext) {
// getRepositoryByParams get repository by a team's organization ID and repo name
func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository {
- repo, err := repo_model.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))
+ repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.Params(":reponame"))
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 58689b72a6..74e6361f6c 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -188,7 +188,7 @@ func SearchIssues(ctx *context.APIContext) {
allPublic = true
opts.AllPublic = false // set it false to avoid returning too many repos, we could filter by indexer
}
- repoIDs, _, err = repo_model.SearchRepositoryIDs(opts)
+ repoIDs, _, err = repo_model.SearchRepositoryIDs(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SearchRepositoryIDs", err)
return
@@ -837,7 +837,7 @@ func EditIssue(ctx *context.APIContext) {
issue.MilestoneID != *form.Milestone {
oldMilestoneID := issue.MilestoneID
issue.MilestoneID = *form.Milestone
- if err = issue_service.ChangeMilestoneAssign(issue, ctx.Doer, oldMilestoneID); err != nil {
+ if err = issue_service.ChangeMilestoneAssign(ctx, issue, ctx.Doer, oldMilestoneID); err != nil {
ctx.Error(http.StatusInternalServerError, "ChangeMilestoneAssign", err)
return
}
diff --git a/routers/api/v1/repo/issue_dependency.go b/routers/api/v1/repo/issue_dependency.go
index 9571532800..0e3bcd93ef 100644
--- a/routers/api/v1/repo/issue_dependency.go
+++ b/routers/api/v1/repo/issue_dependency.go
@@ -576,7 +576,7 @@ func createIssueDependency(ctx *context.APIContext, target, dependency *issues_m
return
}
- err := issues_model.CreateIssueDependency(ctx.Doer, target, dependency)
+ err := issues_model.CreateIssueDependency(ctx, ctx.Doer, target, dependency)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CreateIssueDependency", err)
return
@@ -602,7 +602,7 @@ func removeIssueDependency(ctx *context.APIContext, target, dependency *issues_m
return
}
- err := issues_model.RemoveIssueDependency(ctx.Doer, target, dependency, issues_model.DependencyTypeBlockedBy)
+ err := issues_model.RemoveIssueDependency(ctx, ctx.Doer, target, dependency, issues_model.DependencyTypeBlockedBy)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CreateIssueDependency", err)
return
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index 7d97f5f5e2..e2b7b49438 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -105,7 +105,7 @@ func ListDeployKeys(ctx *context.APIContext) {
apiLink := composeDeployKeysAPILink(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
apiKeys := make([]*api.DeployKey, len(keys))
for i := range keys {
- if err := keys[i].GetContent(); err != nil {
+ if err := keys[i].GetContent(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "GetContent", err)
return
}
@@ -159,7 +159,7 @@ func GetDeployKey(ctx *context.APIContext) {
return
}
- if err = key.GetContent(); err != nil {
+ if err = key.GetContent(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "GetContent", err)
return
}
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go
index 1a86444660..da470dfa74 100644
--- a/routers/api/v1/repo/milestone.go
+++ b/routers/api/v1/repo/milestone.go
@@ -58,7 +58,7 @@ func ListMilestones(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- milestones, total, err := issues_model.GetMilestones(issues_model.GetMilestonesOption{
+ milestones, total, err := issues_model.GetMilestones(ctx, issues_model.GetMilestonesOption{
ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID,
State: api.StateType(ctx.FormString("state")),
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 6fcc5267cf..df9e7217bb 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -555,7 +555,7 @@ func EditPullRequest(ctx *context.APIContext) {
issue.MilestoneID != form.Milestone {
oldMilestoneID := issue.MilestoneID
issue.MilestoneID = form.Milestone
- if err = issue_service.ChangeMilestoneAssign(issue, ctx.Doer, oldMilestoneID); err != nil {
+ if err = issue_service.ChangeMilestoneAssign(ctx, issue, ctx.Doer, oldMilestoneID); err != nil {
ctx.Error(http.StatusInternalServerError, "ChangeMilestoneAssign", err)
return
}
@@ -578,7 +578,7 @@ func EditPullRequest(ctx *context.APIContext) {
labels = append(labels, orgLabels...)
}
- if err = issues_model.ReplaceIssueLabels(issue, labels, ctx.Doer); err != nil {
+ if err = issues_model.ReplaceIssueLabels(ctx, issue, labels, ctx.Doer); err != nil {
ctx.Error(http.StatusInternalServerError, "ReplaceLabelsError", err)
return
}
diff --git a/routers/api/v1/user/avatar.go b/routers/api/v1/user/avatar.go
index 84fa129b13..1c1bb6181a 100644
--- a/routers/api/v1/user/avatar.go
+++ b/routers/api/v1/user/avatar.go
@@ -36,7 +36,7 @@ func UpdateAvatar(ctx *context.APIContext) {
return
}
- err = user_service.UploadAvatar(ctx.Doer, content)
+ err = user_service.UploadAvatar(ctx, ctx.Doer, content)
if err != nil {
ctx.Error(http.StatusInternalServerError, "UploadAvatar", err)
}
@@ -54,7 +54,7 @@ func DeleteAvatar(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
- err := user_service.DeleteAvatar(ctx.Doer)
+ err := user_service.DeleteAvatar(ctx, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAvatar", err)
}
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index 7fc10e82f2..fd891699ce 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -59,14 +59,14 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
// Querying not just listing
if username != "" {
// Restrict to provided uid
- keys, err = asymkey_model.SearchPublicKey(user.ID, fingerprint)
+ keys, err = asymkey_model.SearchPublicKey(ctx, user.ID, fingerprint)
} else {
// Unrestricted
- keys, err = asymkey_model.SearchPublicKey(0, fingerprint)
+ keys, err = asymkey_model.SearchPublicKey(ctx, 0, fingerprint)
}
count = len(keys)
} else {
- total, err2 := asymkey_model.CountPublicKeys(user.ID)
+ total, err2 := asymkey_model.CountPublicKeys(ctx, user.ID)
if err2 != nil {
ctx.InternalServerError(err)
return
@@ -74,7 +74,7 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
count = int(total)
// Use ListPublicKeys
- keys, err = asymkey_model.ListPublicKeys(user.ID, utils.GetListOptions(ctx))
+ keys, err = asymkey_model.ListPublicKeys(ctx, user.ID, utils.GetListOptions(ctx))
}
if err != nil {
@@ -176,7 +176,7 @@ func GetPublicKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- key, err := asymkey_model.GetPublicKeyByID(ctx.ParamsInt64(":id"))
+ key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
ctx.NotFound()
@@ -202,7 +202,7 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
return
}
- key, err := asymkey_model.AddPublicKey(uid, form.Title, content, 0)
+ key, err := asymkey_model.AddPublicKey(ctx, uid, form.Title, content, 0)
if err != nil {
repo.HandleAddKeyError(ctx, err)
return
@@ -262,7 +262,7 @@ func DeletePublicKey(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
id := ctx.ParamsInt64(":id")
- externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(id)
+ externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(ctx, id)
if err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
ctx.NotFound()