mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 16:55:16 +00:00
Rename federatedRepo to followingRepo
This commit is contained in:
parent
d240a9bc90
commit
daccaed157
|
@ -108,7 +108,7 @@ classDiagram
|
||||||
ID int64
|
ID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
class FederatedRepository {
|
class FollowingRepository {
|
||||||
ID int64
|
ID int64
|
||||||
RepositoryID int64
|
RepositoryID int64
|
||||||
ExternalID string
|
ExternalID string
|
||||||
|
@ -122,6 +122,6 @@ classDiagram
|
||||||
PersonID -- FederationHost : mapped by PersonID.Host == FederationHost.HostFqdn
|
PersonID -- FederationHost : mapped by PersonID.Host == FederationHost.HostFqdn
|
||||||
FederatedUser -- FederationHost
|
FederatedUser -- FederationHost
|
||||||
|
|
||||||
Repository *-- FederatedRepository
|
Repository *-- FollowingRepository
|
||||||
FederatedRepository -- FederationHost
|
FollowingRepository -- FederationHost
|
||||||
```
|
```
|
||||||
|
|
|
@ -15,24 +15,24 @@ func init() {
|
||||||
db.RegisterModel(new(FederatedRepo))
|
db.RegisterModel(new(FederatedRepo))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindFederatedReposByRepoID(ctx context.Context, repoId int64) ([]*FederatedRepo, error) {
|
func FindFollowingReposByRepoID(ctx context.Context, repoId int64) ([]*FederatedRepo, error) {
|
||||||
maxFederatedRepos := 10
|
maxFollowingRepos := 10
|
||||||
sess := db.GetEngine(ctx).Where("repo_id=?", repoId)
|
sess := db.GetEngine(ctx).Where("repo_id=?", repoId)
|
||||||
sess = sess.Limit(maxFederatedRepos, 0)
|
sess = sess.Limit(maxFollowingRepos, 0)
|
||||||
federatedRepoList := make([]*FederatedRepo, 0, maxFederatedRepos)
|
federatedRepoList := make([]*FederatedRepo, 0, maxFollowingRepos)
|
||||||
err := sess.Find(&federatedRepoList)
|
err := sess.Find(&federatedRepoList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return make([]*FederatedRepo, 0, maxFederatedRepos), err
|
return make([]*FederatedRepo, 0, maxFollowingRepos), err
|
||||||
}
|
}
|
||||||
for _, federatedRepo := range federatedRepoList {
|
for _, federatedRepo := range federatedRepoList {
|
||||||
if res, err := validation.IsValid(*federatedRepo); !res {
|
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
|
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 {
|
for _, federatedRepo := range federatedRepoList {
|
||||||
if res, err := validation.IsValid(*federatedRepo); !res {
|
if res, err := validation.IsValid(*federatedRepo); !res {
|
||||||
return fmt.Errorf("FederationInfo is not valid: %v", err)
|
return fmt.Errorf("FederationInfo is not valid: %v", err)
|
||||||
|
|
|
@ -380,16 +380,16 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
||||||
ctx.Data["HasAccess"] = true
|
ctx.Data["HasAccess"] = true
|
||||||
ctx.Data["Permission"] = &ctx.Repo.Permission
|
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 {
|
if err == nil {
|
||||||
federatedRepoString := ""
|
followingRepoString := ""
|
||||||
for idx, federatedRepo := range federatedRepoList {
|
for idx, federatedRepo := range federatedRepoList {
|
||||||
if idx > 0 {
|
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 {
|
} else if err != repo_model.ErrMirrorNotExist {
|
||||||
ctx.ServerError("FindFederatedRepoByRepoID", err)
|
ctx.ServerError("FindFederatedRepoByRepoID", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -1993,7 +1993,7 @@ settings.hooks=Webhooks
|
||||||
settings.githooks=Git-Hooks
|
settings.githooks=Git-Hooks
|
||||||
settings.basic_settings=Grundeinstellungen
|
settings.basic_settings=Grundeinstellungen
|
||||||
settings.federation_settings=Föderationseinstellungen
|
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.federation_not_enabled=Föderierung ist auf deiner Instanz nicht aktiviert.
|
||||||
settings.mirror_settings=Mirror-Einstellungen
|
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.
|
settings.mirror_settings.docs=Richte Dein Repository so ein, dass es automatisch Commits, Tags und Branches mit einem anderen Repository synchronisieren kann.
|
||||||
|
|
|
@ -2045,7 +2045,7 @@ settings.hooks = Webhooks
|
||||||
settings.githooks = Git Hooks
|
settings.githooks = Git Hooks
|
||||||
settings.basic_settings = Basic Settings
|
settings.basic_settings = Basic Settings
|
||||||
settings.federation_settings=Federation 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.federation_not_enabled=Federation is not enabled on your instance.
|
||||||
settings.mirror_settings = Mirror Settings
|
settings.mirror_settings = Mirror Settings
|
||||||
settings.mirror_settings.docs = Set up your repository to automatically synchronize commits, tags and branches with another repository.
|
settings.mirror_settings.docs = Set up your repository to automatically synchronize commits, tags and branches with another repository.
|
||||||
|
|
|
@ -197,11 +197,11 @@ func SettingsPost(ctx *context.Context) {
|
||||||
federationRepos := strings.TrimSpace(form.FederationRepos)
|
federationRepos := strings.TrimSpace(form.FederationRepos)
|
||||||
federationRepos = strings.TrimSuffix(federationRepos, ";")
|
federationRepos = strings.TrimSuffix(federationRepos, ";")
|
||||||
|
|
||||||
maxFederatedRepoStrLength := 2048
|
maxFollowingRepoStrLength := 2048
|
||||||
errs := validation.ValidateMaxLen(federationRepos, maxFederatedRepoStrLength, "federationRepos")
|
errs := validation.ValidateMaxLen(federationRepos, maxFollowingRepoStrLength, "federationRepos")
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
ctx.Data["ERR_FederationRepos"] = true
|
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")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ func CreateUserFromAP(ctx context.Context, personID forgefed.PersonID, federatio
|
||||||
|
|
||||||
// Create or update a list of FederatedRepo structs
|
// Create or update a list of FederatedRepo structs
|
||||||
func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRepoList []string) (int, string, error) {
|
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 {
|
for _, uri := range federatedRepoList {
|
||||||
federationHost, err := GetFederationHostForUri(ctx, uri)
|
federationHost, err := GetFederationHostForUri(ctx, uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -229,27 +229,27 @@ func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRep
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusNotAcceptable, "Invalid federated repo", err
|
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
|
return 0, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteFederatedRepos(ctx context.Context, localRepoId int64) error {
|
func DeleteFollowingRepos(ctx context.Context, localRepoId int64) error {
|
||||||
return repo.StoreFederatedRepos(ctx, localRepoId, []*repo.FederatedRepo{})
|
return repo.StoreFollowingRepos(ctx, localRepoId, []*repo.FederatedRepo{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error {
|
func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error {
|
||||||
federatedRepos, err := repo.FindFederatedReposByRepoID(ctx, repoID)
|
followingRepos, err := repo.FindFollowingReposByRepoID(ctx, repoID)
|
||||||
log.Info("Federated Repos is: %v", federatedRepos)
|
log.Info("Federated Repos is: %v", followingRepos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
likeActivityList := make([]forgefed.ForgeLike, 0)
|
likeActivityList := make([]forgefed.ForgeLike, 0)
|
||||||
for _, federatedRepo := range federatedRepos {
|
for _, federatedRepo := range followingRepos {
|
||||||
target := federatedRepo.Uri
|
target := federatedRepo.Uri
|
||||||
likeActivity, err := forgefed.NewForgeLike(doer.APAPIURL(), target, time.Now())
|
likeActivity, err := forgefed.NewForgeLike(doer.APAPIURL(), target, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -67,7 +67,7 @@ func DeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_mod
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
federation_service.DeleteFederatedRepos(ctx, repo.ID)
|
federation_service.DeleteFollowingRepos(ctx, repo.ID)
|
||||||
|
|
||||||
return packages_model.UnlinkRepositoryFromAllPackages(ctx, repo.ID)
|
return packages_model.UnlinkRepositoryFromAllPackages(ctx, repo.ID)
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,9 @@
|
||||||
<form class="ui form" method="post">
|
<form class="ui form" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input type="hidden" name="action" value="federation">
|
<input type="hidden" name="action" value="federation">
|
||||||
<div class="field {{if .Err_FederationRepos}}error{{end}}">
|
<div class="field {{if .Err_FollowingRepos}}error{{end}}">
|
||||||
<label for="federation_repos">{{ctx.Locale.Tr "repo.settings.federation_labelname_repo"}}</label>
|
<label for="following_repos">{{ctx.Locale.Tr "repo.settings.federation_following_repos"}}</label>
|
||||||
<input id="federation_repos" name="federation_repos" value="{{.FederatedRepos}}">
|
<input id="following_repos" name="federation_repos" value="{{.FollowingRepos}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button>
|
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button>
|
||||||
|
|
Loading…
Reference in a new issue