add groups

This commit is contained in:
mr
2026-03-12 08:57:06 +01:00
parent 780a0c530d
commit 80117ee36f
6 changed files with 27 additions and 27 deletions

View File

@@ -54,7 +54,7 @@ type StreamService struct {
Key pp.ID
Host host.Host
Node common.DiscoveryPeer
Streams common.ProtocolStream
Streams common.ProtocolStream
maxNodesConn int
Mu sync.RWMutex
}
@@ -65,7 +65,7 @@ func InitStream(ctx context.Context, h host.Host, key pp.ID, maxNode int, node c
Key: key,
Node: node,
Host: h,
Streams: common.ProtocolStream{},
Streams: common.ProtocolStream{},
maxNodesConn: maxNode,
}
for proto := range protocols {
@@ -101,7 +101,6 @@ func (s *StreamService) HandleResponse(stream network.Stream) {
stream.Protocol(), protocols[stream.Protocol()])
}
func (s *StreamService) connectToPartners() error {
logger := oclib.GetLogger()
// Register handlers for partner resource protocols (create/update/delete).
@@ -123,7 +122,6 @@ func (s *StreamService) connectToPartners() error {
return nil
}
func (s *StreamService) searchPeer(search string) ([]*peer.Peer, error) {
ps := []*peer.Peer{}
if conf.GetConfig().PeerIDS != "" {
@@ -219,11 +217,12 @@ func (ps *StreamService) readLoop(s *common.Stream, id pp.ID, proto protocol.ID,
}
}
func (abs *StreamService) FilterPeer(peerID string, search string) *dbs.Filters {
func (abs *StreamService) FilterPeer(peerID string, groups []string, search string) *dbs.Filters {
p, err := oclib.GetMySelf()
if err != nil {
return nil
}
groups = append(groups, "*")
filter := map[string][]dbs.Filter{
"abstractinstanciatedresource.abstractresource.abstractobject.creator_id": {{Operator: dbs.EQUAL.String(), Value: p.GetID()}}, // is my resource...
"": {{Operator: dbs.OR.String(), Value: &dbs.Filters{
@@ -233,7 +232,7 @@ func (abs *StreamService) FilterPeer(peerID string, search string) *dbs.Filters
And: map[string][]dbs.Filter{
"resourceinstance.partnerships": {{Operator: dbs.ELEMMATCH.String(), Value: &dbs.Filters{
And: map[string][]dbs.Filter{
"resourcepartnership.peer_groups." + peerID: {{Operator: dbs.EXISTS.String(), Value: true}},
"resourcepartnership.peer_groups." + peerID: {{Operator: dbs.IN.String(), Value: groups}},
},
}}},
},