delete federated repos when deleting repository

This commit is contained in:
Clemens 2024-04-02 12:36:04 +02:00
parent 8b56159042
commit 962cd374e2
2 changed files with 10 additions and 0 deletions

View file

@ -237,6 +237,13 @@ func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRep
return 0, "", nil
}
func DeleteFederatedRepos(ctx context.Context, localRepoId int64) error {
if err := repo.StoreFederatedRepos(ctx, localRepoId, []*repo.FederatedRepo{}); err != nil {
return err
}
return nil
}
func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error {
federatedRepos, err := repo.FindFederatedReposByRepoID(ctx, repoID)
log.Info("Federated Repos is: %v", federatedRepos)

View file

@ -21,6 +21,7 @@ import (
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
federation_service "code.gitea.io/gitea/services/federation"
notify_service "code.gitea.io/gitea/services/notify"
pull_service "code.gitea.io/gitea/services/pull"
)
@ -66,6 +67,8 @@ func DeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_mod
return err
}
federation_service.DeleteFederatedRepos(ctx, repo.ID)
return packages_model.UnlinkRepositoryFromAllPackages(ctx, repo.ID)
}