|
@@ -2,32 +2,26 @@ package stream
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+
|
|
|
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
|
|
"github.com/0xJacky/Nginx-UI/model"
|
|
|
"github.com/0xJacky/Nginx-UI/query"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"github.com/go-resty/resty/v2"
|
|
|
- "github.com/samber/lo"
|
|
|
"github.com/uozi-tech/cosy/logger"
|
|
|
)
|
|
|
|
|
|
// getSyncNodes returns the nodes that need to be synchronized by site name
|
|
|
func getSyncNodes(name string) (nodes []*model.Environment) {
|
|
|
configFilePath := nginx.GetConfPath("streams-available", name)
|
|
|
- s := query.Site
|
|
|
- site, err := s.Where(s.Path.Eq(configFilePath)).
|
|
|
- Preload(s.SiteCategory).First()
|
|
|
+ s := query.Stream
|
|
|
+ stream, err := s.Where(s.Path.Eq(configFilePath)).First()
|
|
|
if err != nil {
|
|
|
logger.Error(err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- syncNodeIds := site.SyncNodeIDs
|
|
|
- // inherit sync node ids from site category
|
|
|
- if site.SiteCategory != nil {
|
|
|
- syncNodeIds = append(syncNodeIds, site.SiteCategory.SyncNodeIds...)
|
|
|
- }
|
|
|
- syncNodeIds = lo.Uniq(syncNodeIds)
|
|
|
+ syncNodeIds := stream.SyncNodeIDs
|
|
|
|
|
|
e := query.Environment
|
|
|
nodes, err = e.Where(e.ID.In(syncNodeIds...)).Find()
|