Correct logic for default site condition

This commit is contained in:
Sofiane A 2025-04-29 19:34:52 +02:00
parent 5a89a4634a
commit 10ccd0c2d7
1 changed files with 3 additions and 5 deletions

View File

@ -280,11 +280,9 @@ func (u *InputUnifi) getFilteredSites(c *Controller) ([]*unifi.Site, error) {
return nil, fmt.Errorf("controller: %w", err)
}
// Apply the default_site_name_override if the site is marked as default.
for _, site := range sites {
if site.IsDefaultSite && c.DefaultSiteNameOverride != "" {
site.Name = c.DefaultSiteNameOverride
}
// Apply the default_site_name_override to the first site in the list, if configured.
if len(sites) > 0 && c.DefaultSiteNameOverride != "" {
sites[0].Name = c.DefaultSiteNameOverride
}
if len(c.Sites) == 0 || StringInSlice("all", c.Sites) {