diff --git a/docs/unsure-where-to-put/federation-architecture.md b/docs/unsure-where-to-put/federation-architecture.md index 11e8590f32..bd6c31fbfc 100644 --- a/docs/unsure-where-to-put/federation-architecture.md +++ b/docs/unsure-where-to-put/federation-architecture.md @@ -108,7 +108,7 @@ classDiagram ID int64 } - class FederatedRepository { + class FollowingRepository { ID int64 RepositoryID int64 ExternalID string @@ -122,6 +122,6 @@ classDiagram PersonID -- FederationHost : mapped by PersonID.Host == FederationHost.HostFqdn FederatedUser -- FederationHost - Repository *-- FederatedRepository - FederatedRepository -- FederationHost + Repository *-- FollowingRepository + FollowingRepository -- FederationHost ``` diff --git a/models/repo/repo_repository.go b/models/repo/repo_repository.go index e3c5a87b4e..66a1c13ab5 100644 --- a/models/repo/repo_repository.go +++ b/models/repo/repo_repository.go @@ -15,24 +15,24 @@ func init() { db.RegisterModel(new(FederatedRepo)) } -func FindFederatedReposByRepoID(ctx context.Context, repoId int64) ([]*FederatedRepo, error) { - maxFederatedRepos := 10 +func FindFollowingReposByRepoID(ctx context.Context, repoId int64) ([]*FederatedRepo, error) { + maxFollowingRepos := 10 sess := db.GetEngine(ctx).Where("repo_id=?", repoId) - sess = sess.Limit(maxFederatedRepos, 0) - federatedRepoList := make([]*FederatedRepo, 0, maxFederatedRepos) + sess = sess.Limit(maxFollowingRepos, 0) + federatedRepoList := make([]*FederatedRepo, 0, maxFollowingRepos) err := sess.Find(&federatedRepoList) if err != nil { - return make([]*FederatedRepo, 0, maxFederatedRepos), err + return make([]*FederatedRepo, 0, maxFollowingRepos), err } for _, federatedRepo := range federatedRepoList { if res, err := validation.IsValid(*federatedRepo); !res { - return make([]*FederatedRepo, 0, maxFederatedRepos), fmt.Errorf("FederationInfo is not valid: %v", err) + return make([]*FederatedRepo, 0, maxFollowingRepos), fmt.Errorf("FederationInfo is not valid: %v", err) } } return federatedRepoList, nil } -func StoreFederatedRepos(ctx context.Context, localRepoId int64, federatedRepoList []*FederatedRepo) error { +func StoreFollowingRepos(ctx context.Context, localRepoId int64, federatedRepoList []*FederatedRepo) error { for _, federatedRepo := range federatedRepoList { if res, err := validation.IsValid(*federatedRepo); !res { return fmt.Errorf("FederationInfo is not valid: %v", err) diff --git a/modules/context/repo.go b/modules/context/repo.go index 6a8d1fe036..a6ab7df3cf 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -380,16 +380,16 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) { ctx.Data["HasAccess"] = true ctx.Data["Permission"] = &ctx.Repo.Permission - federatedRepoList, err := repo_model.FindFederatedReposByRepoID(ctx, repo.ID) + federatedRepoList, err := repo_model.FindFollowingReposByRepoID(ctx, repo.ID) if err == nil { - federatedRepoString := "" + followingRepoString := "" for idx, federatedRepo := range federatedRepoList { if idx > 0 { - federatedRepoString += ";" + followingRepoString += ";" } - federatedRepoString += (*federatedRepo).Uri + followingRepoString += (*federatedRepo).Uri } - ctx.Data["FederatedRepos"] = federatedRepoString + ctx.Data["FollowingRepos"] = followingRepoString } else if err != repo_model.ErrMirrorNotExist { ctx.ServerError("FindFederatedRepoByRepoID", err) return diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index 4b4f27b84f..dadd32dc26 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -1993,7 +1993,7 @@ settings.hooks=Webhooks settings.githooks=Git-Hooks settings.basic_settings=Grundeinstellungen settings.federation_settings=Föderationseinstellungen -settings.federation_labelname_repo=URLs der föderierten Repositories. Getrennt mittels ";", keine Leerzeichen. +settings.federation_following_repos=URLs der Repos, die diesem Repo folgen. Getrennt mittels ";", keine Leerzeichen. settings.federation_not_enabled=Föderierung ist auf deiner Instanz nicht aktiviert. settings.mirror_settings=Mirror-Einstellungen settings.mirror_settings.docs=Richte Dein Repository so ein, dass es automatisch Commits, Tags und Branches mit einem anderen Repository synchronisieren kann. diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 6fdda4238b..4dfacd0e15 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2045,7 +2045,7 @@ settings.hooks = Webhooks settings.githooks = Git Hooks settings.basic_settings = Basic Settings settings.federation_settings=Federation Settings -settings.federation_labelname_repo=URLs of Federated Repositories. Separated by ";", no whitespace. +settings.federation_following_repos=URLs of Following Repositories. Separated by ";", no whitespace. settings.federation_not_enabled=Federation is not enabled on your instance. settings.mirror_settings = Mirror Settings settings.mirror_settings.docs = Set up your repository to automatically synchronize commits, tags and branches with another repository. diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index 4d5fa93317..1b8d439edf 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -197,11 +197,11 @@ func SettingsPost(ctx *context.Context) { federationRepos := strings.TrimSpace(form.FederationRepos) federationRepos = strings.TrimSuffix(federationRepos, ";") - maxFederatedRepoStrLength := 2048 - errs := validation.ValidateMaxLen(federationRepos, maxFederatedRepoStrLength, "federationRepos") + maxFollowingRepoStrLength := 2048 + errs := validation.ValidateMaxLen(federationRepos, maxFollowingRepoStrLength, "federationRepos") if len(errs) > 0 { ctx.Data["ERR_FederationRepos"] = true - ctx.Flash.Error(ctx.Tr("repo.form.string_too_long", maxFederatedRepoStrLength)) + ctx.Flash.Error(ctx.Tr("repo.form.string_too_long", maxFollowingRepoStrLength)) ctx.Redirect(repo.Link() + "/settings") return } diff --git a/services/federation/federation_service.go b/services/federation/federation_service.go index b27f2a6b0c..b68de15400 100644 --- a/services/federation/federation_service.go +++ b/services/federation/federation_service.go @@ -215,7 +215,7 @@ func CreateUserFromAP(ctx context.Context, personID forgefed.PersonID, federatio // Create or update a list of FederatedRepo structs func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRepoList []string) (int, string, error) { - federatedRepos := make([]*repo.FederatedRepo, 0, len(federatedRepoList)) + followingRepos := make([]*repo.FederatedRepo, 0, len(federatedRepoList)) for _, uri := range federatedRepoList { federationHost, err := GetFederationHostForUri(ctx, uri) if err != nil { @@ -229,27 +229,27 @@ func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRep if err != nil { return http.StatusNotAcceptable, "Invalid federated repo", err } - federatedRepos = append(federatedRepos, &federatedRepo) + followingRepos = append(followingRepos, &federatedRepo) } - repo.StoreFederatedRepos(ctx, localRepoId, federatedRepos) + repo.StoreFollowingRepos(ctx, localRepoId, followingRepos) return 0, "", nil } -func DeleteFederatedRepos(ctx context.Context, localRepoId int64) error { - return repo.StoreFederatedRepos(ctx, localRepoId, []*repo.FederatedRepo{}) +func DeleteFollowingRepos(ctx context.Context, localRepoId int64) error { + return repo.StoreFollowingRepos(ctx, localRepoId, []*repo.FederatedRepo{}) } func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error { - federatedRepos, err := repo.FindFederatedReposByRepoID(ctx, repoID) - log.Info("Federated Repos is: %v", federatedRepos) + followingRepos, err := repo.FindFollowingReposByRepoID(ctx, repoID) + log.Info("Federated Repos is: %v", followingRepos) if err != nil { return err } likeActivityList := make([]forgefed.ForgeLike, 0) - for _, federatedRepo := range federatedRepos { + for _, federatedRepo := range followingRepos { target := federatedRepo.Uri likeActivity, err := forgefed.NewForgeLike(doer.APAPIURL(), target, time.Now()) if err != nil { diff --git a/services/repository/repository.go b/services/repository/repository.go index af0e5fee4d..30fb1767da 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -67,7 +67,7 @@ func DeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_mod return err } - federation_service.DeleteFederatedRepos(ctx, repo.ID) + federation_service.DeleteFollowingRepos(ctx, repo.ID) return packages_model.UnlinkRepositoryFromAllPackages(ctx, repo.ID) } diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 861a50c92e..a4eb2836ef 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -71,9 +71,9 @@
{{.CsrfTokenHtml}} -
- - +
+ +