diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index 2e37499c59..9d6c6f7f0c 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -14,10 +14,10 @@ import ( 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/forgefed" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/utils" "code.gitea.io/gitea/services/convert" + "code.gitea.io/gitea/services/repository" ) // getStarredRepos returns the repos that the user with the specified userID has @@ -157,7 +157,7 @@ func Star(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - err := forgefed.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, true) + err := repository.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, true) if err != nil { ctx.Error(http.StatusInternalServerError, "StarRepo", err) return @@ -188,7 +188,7 @@ func Unstar(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - err := forgefed.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, false) + err := repository.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, false) if err != nil { ctx.Error(http.StatusInternalServerError, "StarRepo", err) return diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index dd630b5ff3..7f72599bca 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -23,7 +23,6 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/forgefed" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" @@ -34,6 +33,7 @@ import ( "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/convert" "code.gitea.io/gitea/services/forms" + "code.gitea.io/gitea/services/repository" repo_service "code.gitea.io/gitea/services/repository" archiver_service "code.gitea.io/gitea/services/repository/archiver" ) @@ -318,9 +318,9 @@ func Action(ctx *context.Context) { case "unwatch": err = repo_model.WatchRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, false) case "star": - err = forgefed.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, true) + err = repository.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, true) case "unstar": - err = forgefed.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, false) + err = repository.StarRepoAndFederate(ctx, *ctx.Doer, ctx.Repo.Repository.ID, false) case "accept_transfer": err = acceptOrRejectRepoTransfer(ctx, true) case "reject_transfer": diff --git a/services/federation/federation_service.go b/services/federation/federation_service.go index 2f77630578..bb3417f7d3 100644 --- a/services/federation/federation_service.go +++ b/services/federation/federation_service.go @@ -82,7 +82,7 @@ func ProcessLikeActivity(ctx context.Context, form any, repositoryID int64) (int // execute the activity if the repo was not stared already alreadyStared := repo.IsStaring(ctx, user.ID, repositoryID) if !alreadyStared { - err = StarRepoAndFederate(ctx, *user, repositoryID, true) + err = repo.StarRepo(ctx, user.ID, repositoryID, true) if err != nil { return http.StatusNotAcceptable, "Error staring", err } @@ -271,17 +271,3 @@ func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error return nil } - -func StarRepoAndFederate(ctx context.Context, doer user.User, repoID int64, star bool) error { - if err := repo.StarRepo(ctx, doer.ID, repoID, star); err != nil { - return err - } - - if star && setting.Federation.Enabled { - if err := SendLikeActivities(ctx, doer, repoID); err != nil { - return err - } - } - - return nil -} diff --git a/services/repository/star.go b/services/repository/star.go index 50cd1623aa..e9f4c1cdef 100644 --- a/services/repository/star.go +++ b/services/repository/star.go @@ -12,8 +12,8 @@ import ( "code.gitea.io/gitea/services/federation" ) -func StarRepo(ctx context.Context, doer user.User, repoID int64, star bool) error { - if err := repo.StarLocalRepo(ctx, doer.ID, repoID, star); err != nil { +func StarRepoAndFederate(ctx context.Context, doer user.User, repoID int64, star bool) error { + if err := repo.StarRepo(ctx, doer.ID, repoID, star); err != nil { return err }