diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index 2659789ddd..a07407ffc3 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -7,12 +7,16 @@ package user import ( std_context "context" "net/http" + "strings" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/forgefed" access_model "code.gitea.io/gitea/models/perm/access" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/activitypub" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/utils" "code.gitea.io/gitea/services/convert" @@ -160,6 +164,32 @@ func Star(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "StarRepo", err) return } + if setting.Federation.Enabled { + + likeActivity, err := forgefed.NewForgeLike(ctx) + if err != nil { + ctx.Error(http.StatusInternalServerError, "StarRepo", err) + return + } + + json, err := likeActivity.MarshalJSON() + if err != nil { + ctx.Error(http.StatusInternalServerError, "StarRepo", err) + return + } + + apclient, err := activitypub.NewClient(ctx, ctx.Doer, ctx.Doer.APAPIURL()) + if err != nil { + ctx.Error(http.StatusInternalServerError, "StarRepo", err) + return + } + // ToDo: Change this to the standalone table of FederatedRepos + for _, target := range strings.Split(ctx.Repo.Repository.FederationRepos, ";") { + apclient.Post([]byte(json), target) + } + + // Send to list of federated repos + } ctx.Status(http.StatusNoContent) }