fix(subscribe): add Enabled filter to node query parameters
This commit is contained in:
parent
c1c324878b
commit
d2ca3eb961
@ -212,12 +212,15 @@ func (l *SubscribeLogic) getServers(userSub *user.Subscribe) ([]*node.Node, erro
|
|||||||
|
|
||||||
l.Debugf("[Generate Subscribe]nodes: %v, NodeTags: %v", nodeIds, tags)
|
l.Debugf("[Generate Subscribe]nodes: %v, NodeTags: %v", nodeIds, tags)
|
||||||
|
|
||||||
|
enable := true
|
||||||
|
|
||||||
_, nodes, err := l.svc.NodeModel.FilterNodeList(l.ctx.Request.Context(), &node.FilterNodeParams{
|
_, nodes, err := l.svc.NodeModel.FilterNodeList(l.ctx.Request.Context(), &node.FilterNodeParams{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
Size: 1000,
|
Size: 1000,
|
||||||
ServerId: nodeIds,
|
ServerId: nodeIds,
|
||||||
Tag: tool.RemoveDuplicateElements(tags...),
|
Tag: tool.RemoveDuplicateElements(tags...),
|
||||||
Preload: true,
|
Preload: true,
|
||||||
|
Enabled: &enable, // Only get enabled nodes
|
||||||
})
|
})
|
||||||
|
|
||||||
l.Debugf("[Query Subscribe]found servers: %v", len(nodes))
|
l.Debugf("[Query Subscribe]found servers: %v", len(nodes))
|
||||||
|
|||||||
@ -37,6 +37,7 @@ type FilterNodeParams struct {
|
|||||||
Search string // Search Address or Name
|
Search string // Search Address or Name
|
||||||
Protocol string // Protocol
|
Protocol string // Protocol
|
||||||
Preload bool // Preload Server
|
Preload bool // Preload Server
|
||||||
|
Enabled *bool // Enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterServerList Filter Server List
|
// FilterServerList Filter Server List
|
||||||
@ -88,6 +89,10 @@ func (m *customServerModel) FilterNodeList(ctx context.Context, params *FilterNo
|
|||||||
query = query.Where("protocol = ?", params.Protocol)
|
query = query.Where("protocol = ?", params.Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.Enabled != nil {
|
||||||
|
query = query.Where("enabled = ?", *params.Enabled)
|
||||||
|
}
|
||||||
|
|
||||||
if params.Preload {
|
if params.Preload {
|
||||||
query = query.Preload("Server")
|
query = query.Preload("Server")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user