aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-12 23:48:20 +0800
committerGitHub <noreply@github.com>2021-12-12 23:48:20 +0800
commit572324049008ac803d3d7c17a7b3a81ef00386fc (patch)
treea9c3709643a23165d27aa67e76f10f26a89936d5 /routers/api/v1/user
parent0a7e8327a017c5dd43e552bbcd0d0f056bc1671b (diff)
downloadgitea-572324049008ac803d3d7c17a7b3a81ef00386fc.tar.gz
gitea-572324049008ac803d3d7c17a7b3a81ef00386fc.zip
Some repository refactors (#17950)
* some repository refactors * remove unnecessary code * Fix test * Remove unnecessary banner
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r--routers/api/v1/user/star.go7
-rw-r--r--routers/api/v1/user/watch.go6
2 files changed, 7 insertions, 6 deletions
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index 946ae738e9..14bc23b1c3 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
@@ -121,7 +122,7 @@ func IsStarring(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if models.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) {
+ if repo_model.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) {
ctx.Status(http.StatusNoContent)
} else {
ctx.NotFound()
@@ -148,7 +149,7 @@ func Star(ctx *context.APIContext) {
// "204":
// "$ref": "#/responses/empty"
- err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
+ err := repo_model.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
@@ -176,7 +177,7 @@ func Unstar(ctx *context.APIContext) {
// "204":
// "$ref": "#/responses/empty"
- err := models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
+ err := repo_model.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
if err != nil {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 5c7a4d8d89..6c3e1c86fa 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -123,7 +123,7 @@ func IsWatching(ctx *context.APIContext) {
// "404":
// description: User is not watching this repo or repo do not exist
- if models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) {
+ if repo_model.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) {
ctx.JSON(http.StatusOK, api.WatchInfo{
Subscribed: true,
Ignored: false,
@@ -157,7 +157,7 @@ func Watch(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/WatchInfo"
- err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
+ err := repo_model.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "WatchRepo", err)
return
@@ -193,7 +193,7 @@ func Unwatch(ctx *context.APIContext) {
// "204":
// "$ref": "#/responses/empty"
- err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
+ err := repo_model.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
if err != nil {
ctx.Error(http.StatusInternalServerError, "UnwatchRepo", err)
return