fix(subscribe): add Enabled filter to node query parameters

This commit is contained in:
Chang lue Tsen 2025-09-27 10:18:08 -04:00
parent c1c324878b
commit d2ca3eb961
2 changed files with 8 additions and 0 deletions

View File

@ -212,12 +212,15 @@ func (l *SubscribeLogic) getServers(userSub *user.Subscribe) ([]*node.Node, erro
l.Debugf("[Generate Subscribe]nodes: %v, NodeTags: %v", nodeIds, tags)
enable := true
_, nodes, err := l.svc.NodeModel.FilterNodeList(l.ctx.Request.Context(), &node.FilterNodeParams{
Page: 1,
Size: 1000,
ServerId: nodeIds,
Tag: tool.RemoveDuplicateElements(tags...),
Preload: true,
Enabled: &enable, // Only get enabled nodes
})
l.Debugf("[Query Subscribe]found servers: %v", len(nodes))

View File

@ -37,6 +37,7 @@ type FilterNodeParams struct {
Search string // Search Address or Name
Protocol string // Protocol
Preload bool // Preload Server
Enabled *bool // Enabled
}
// FilterServerList Filter Server List
@ -88,6 +89,10 @@ func (m *customServerModel) FilterNodeList(ctx context.Context, params *FilterNo
query = query.Where("protocol = ?", params.Protocol)
}
if params.Enabled != nil {
query = query.Where("enabled = ?", *params.Enabled)
}
if params.Preload {
query = query.Preload("Server")
}