WIP Implement proper saving of federated repo urls

Added ToDos where relevant
This commit is contained in:
erik 2024-03-19 15:25:52 +01:00
parent 9337274334
commit 884e38bdab
3 changed files with 19 additions and 4 deletions

View file

@ -137,7 +137,7 @@ type Repository struct {
DefaultBranch string DefaultBranch string
WikiBranch string WikiBranch string
// TODO: Create own table out of this field // TODO: Create own table out of this field
FederationRepos string FederationRepos string `xorm:"TEXT"`
NumWatches int NumWatches int
NumStars int NumStars int

View file

@ -188,7 +188,20 @@ func SettingsPost(ctx *context.Context) {
case "federation": case "federation":
if !setting.Federation.Enabled { if !setting.Federation.Enabled {
ctx.NotFound("", nil) ctx.NotFound("", nil)
ctx.Flash.Info("Federation Not enabled")
return return
} else {
// ToDo: Proper string handling
log.Info("web/repo/setting.go:Federation was detected as enabled.")
// ToDo: Ability to delete repos
repo.FederationRepos = repo.FederationRepos + form.FederationRepos
if err := repo_service.UpdateRepository(ctx, repo, false); err != nil {
ctx.ServerError("UpdateRepository", err)
return
}
log.Info("Repos are: %v", repo.FederationRepos)
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
ctx.Redirect(repo.Link() + "/settings")
} }
// TODO: Validate semicolon separation // TODO: Validate semicolon separation

View file

@ -113,6 +113,8 @@ type RepoSettingForm struct {
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"` RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
Description string `binding:"MaxSize(2048)"` Description string `binding:"MaxSize(2048)"`
Website string `binding:"ValidUrl;MaxSize(1024)"` Website string `binding:"ValidUrl;MaxSize(1024)"`
// ToDo: Do we need validation at this point?
FederationRepos string
Interval string Interval string
MirrorAddress string MirrorAddress string
MirrorUsername string MirrorUsername string