1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-21 08:31:27 -05:00

Rename federatedRepo to followingRepo

This commit is contained in:
erik 2024-04-03 12:08:44 +02:00
parent d240a9bc90
commit daccaed157
9 changed files with 32 additions and 32 deletions

View file

@ -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
```

View file

@ -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)

View file

@ -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

View file

@ -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.

View file

@ -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.

View file

@ -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
}

View file

@ -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 {

View file

@ -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)
}

View file

@ -71,9 +71,9 @@
<form class="ui form" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="federation">
<div class="field {{if .Err_FederationRepos}}error{{end}}">
<label for="federation_repos">{{ctx.Locale.Tr "repo.settings.federation_labelname_repo"}}</label>
<input id="federation_repos" name="federation_repos" value="{{.FederatedRepos}}">
<div class="field {{if .Err_FollowingRepos}}error{{end}}">
<label for="following_repos">{{ctx.Locale.Tr "repo.settings.federation_following_repos"}}</label>
<input id="following_repos" name="federation_repos" value="{{.FollowingRepos}}">
</div>
<div class="field">
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button>