@@ -34,6 +34,8 @@ import (
34
34
"go.opencensus.io/trace"
35
35
36
36
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
37
+ collaborationv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
38
+ linkv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
37
39
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
38
40
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/conversions"
39
41
"github.com/cs3org/reva/pkg/appctx"
@@ -283,6 +285,44 @@ func (s *svc) newProp(key, val string) *propertyXML {
283
285
// ns is the CS3 namespace that needs to be removed from the CS3 path before
284
286
// prefixing it with the baseURI
285
287
func (s * svc ) mdToPropResponse (ctx context.Context , pf * propfindXML , md * provider.ResourceInfo , ns string ) (* responseXML , error ) {
288
+ log := appctx .GetLogger (ctx )
289
+
290
+ client , err := s .getClient ()
291
+ if err != nil {
292
+ log .Error ().Err (err ).Msg ("error getting grpc client" )
293
+ return nil , err
294
+ }
295
+
296
+ lsReq := & collaborationv1beta1.ListSharesRequest {
297
+ Filters : []* collaborationv1beta1.ListSharesRequest_Filter {
298
+ {
299
+ Type : collaborationv1beta1 .ListSharesRequest_Filter_TYPE_RESOURCE_ID ,
300
+ Term : & collaborationv1beta1.ListSharesRequest_Filter_ResourceId {
301
+ ResourceId : md .Id ,
302
+ },
303
+ },
304
+ },
305
+ }
306
+ lsResp , err := client .ListShares (ctx , lsReq )
307
+ if err != nil {
308
+ log .Error ().Err (err ).Msg ("error getting shares" )
309
+ }
310
+
311
+ lpsReq := & linkv1beta1.ListPublicSharesRequest {
312
+ Filters : []* linkv1beta1.ListPublicSharesRequest_Filter {
313
+ {
314
+ Type : linkv1beta1 .ListPublicSharesRequest_Filter_TYPE_RESOURCE_ID ,
315
+ Term : & linkv1beta1.ListPublicSharesRequest_Filter_ResourceId {
316
+ ResourceId : md .Id ,
317
+ },
318
+ },
319
+ },
320
+ }
321
+
322
+ lpsResp , err := client .ListPublicShares (ctx , lpsReq )
323
+ if err != nil {
324
+ log .Error ().Err (err ).Msg ("error getting public shares" )
325
+ }
286
326
287
327
md .Path = strings .TrimPrefix (md .Path , ns )
288
328
@@ -462,7 +502,17 @@ func (s *svc) mdToPropResponse(ctx context.Context, pf *propfindXML, md *provide
462
502
// <oc:share-types>
463
503
// <oc:share-type>1</oc:share-type>
464
504
// </oc:share-types>
465
- fallthrough
505
+ var types []string
506
+ if lpsResp .Status .Code == rpc .Code_CODE_OK && len (lpsResp .Share ) != 0 {
507
+ types = append (types , fmt .Sprintf ("<oc:share-type>%d</oc:share-type>" , conversions .ShareTypePublicLink ))
508
+ }
509
+ if lsResp .Status .Code == rpc .Code_CODE_OK && len (lsResp .Shares ) != 0 {
510
+ types = append (types , fmt .Sprintf ("<oc:share-type>%d</oc:share-type>" , conversions .ShareTypeUser ))
511
+ }
512
+
513
+ if len (types ) > 0 {
514
+ propstatOK .Prop = append (propstatOK .Prop , s .newProp ("oc:share-types" , strings .Join (types , "" )))
515
+ }
466
516
default :
467
517
propstatNotFound .Prop = append (propstatNotFound .Prop , s .newProp ("oc:" + pf .Prop [i ].Local , "" ))
468
518
}
0 commit comments