Skip to content

Commit

Permalink
The hidden shares have been excluded from a search result
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Jun 18, 2024
1 parent 8dbc162 commit 570de39
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-search-hidden.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: The hidden shares have been excluded from a search result

The hidden shares have been excluded from a search result.

https://github.com/owncloud/ocis/pull/9371
https://github.com/owncloud/ocis/issues/7383
20 changes: 19 additions & 1 deletion services/search/pkg/search/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
collaborationv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/errtypes"
Expand Down Expand Up @@ -323,6 +324,23 @@ func (s *Service) searchIndex(ctx context.Context, req *searchsvc.SearchRequest,
s.logger.Error().Err(err).Str("space", space.Id.OpaqueId).Str("mountpointId", mountpointID).Msg("invalid mountpoint space id")
return nil, errSkipSpace
}
// exclude the hidden shares
rs, err := gatewayClient.GetReceivedShare(ctx, &collaborationv1beta1.GetReceivedShareRequest{
Ref: &collaborationv1beta1.ShareReference{
Spec: &collaborationv1beta1.ShareReference_Id{
Id: &collaborationv1beta1.ShareId{
OpaqueId: oid,
},
},
},
})
if err != nil {
s.logger.Error().Err(err).Str("space", space.Id.OpaqueId).Str("shareId", oid).Msg("invalid receive share")
}
if rs.GetStatus().GetCode() == rpcv1beta1.Code_CODE_OK && rs.GetShare().GetHidden() {
return nil, errSkipSpace
}

mountpointRootID = &searchmsg.ResourceID{
StorageId: sid,
SpaceId: spid,
Expand Down Expand Up @@ -361,7 +379,7 @@ func (s *Service) searchIndex(ctx context.Context, req *searchsvc.SearchRequest,
s.logger.Debug().Interface("searchRequest", searchRequest).Str("duration", fmt.Sprint(duration)).Str("space", space.Id.OpaqueId).Int("hits", len(res.Matches)).Msg("space search done")
}

var matches []*searchmsg.Match
matches := make([]*searchmsg.Match, 0, len(res.Matches))

for _, match := range res.Matches {
if mountpointPrefix != "" {
Expand Down
4 changes: 4 additions & 0 deletions services/search/pkg/search/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
collaborationv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
sprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
Expand Down Expand Up @@ -101,6 +102,9 @@ var _ = Describe("Searchprovider", func() {
Status: status.NewOK(context.Background()),
Path: ri.Path,
}, nil)
gatewayClient.On("GetReceivedShare", mock.Anything, mock.Anything).Return(&collaborationv1beta1.GetReceivedShareResponse{
Status: status.NewOK(ctx),
}, nil)
indexClient.On("DocCount").Return(uint64(1), nil)
})

Expand Down

0 comments on commit 570de39

Please sign in to comment.