Skip to content

Commit fac368a

Browse files
authored
Merge pull request #10757 from 2403905/issue-e7004-2
Made GetScopeByKeyPrefix function as a private method of the FileConnector
2 parents ffe56db + 8d1f990 commit fac368a

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: Fix FileInfo BreadcrumbFolderURL upd
2+
3+
Made GetScopeByKeyPrefix function as a private method of the FileConnector
4+
5+
https://github.com/owncloud/ocis/pull/10757

services/collaboration/pkg/connector/fileconnector.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import (
66
"encoding/base64"
77
"encoding/binary"
88
"encoding/hex"
9+
"fmt"
910
"io"
1011
"net/url"
1112
"path"
1213
"strings"
1314
"time"
1415

1516
appproviderv1beta1 "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1"
17+
auth "github.com/cs3org/go-cs3apis/cs3/auth/provider/v1beta1"
1618
gatewayv1beta1 "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
1719
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
1820
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
@@ -23,6 +25,7 @@ import (
2325
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
2426
"github.com/cs3org/reva/v2/pkg/storagespace"
2527
"github.com/cs3org/reva/v2/pkg/utils"
28+
"github.com/golang/protobuf/proto"
2629
"github.com/google/uuid"
2730
"github.com/owncloud/ocis/v2/services/collaboration/pkg/config"
2831
"github.com/owncloud/ocis/v2/services/collaboration/pkg/connector/fileinfo"
@@ -1230,7 +1233,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
12301233
} else {
12311234
if scopes, ok := ctxpkg.ContextGetScopes(ctx); ok {
12321235
publicShare := &link.PublicShare{}
1233-
if err := helpers.GetScopeByKeyPrefix(scopes, "publicshare:", publicShare); err == nil {
1236+
if err := f.getScopeByKeyPrefix(scopes, "publicshare:", publicShare); err == nil {
12341237
parentFolderURL.Path = path.Join(ocisURL.Path, "s", publicShare.GetToken())
12351238
} else {
12361239
logger.Error().Err(err).Msg("CheckFileInfo: error getting public share scope")
@@ -1483,3 +1486,17 @@ func (f *FileConnector) adjustWopiReference(ctx context.Context, wopiContext *mi
14831486

14841487
return newStatRes.GetInfo(), nil
14851488
}
1489+
1490+
// getScopeByKeyPrefix returns the scope from the AccessToken Scope map by key prefix
1491+
func (f *FileConnector) getScopeByKeyPrefix(scopes map[string]*auth.Scope, keyPrefix string, m proto.Message) error {
1492+
for k, v := range scopes {
1493+
if strings.HasPrefix(k, keyPrefix) && v.Resource.Decoder == "json" {
1494+
err := utils.UnmarshalJSONToProtoV1(v.Resource.Value, m)
1495+
if err != nil {
1496+
return fmt.Errorf("can't unmarshal public share from scope: %w", err)
1497+
}
1498+
return nil
1499+
}
1500+
}
1501+
return fmt.Errorf("scope %s not found", keyPrefix)
1502+
}

services/collaboration/pkg/helpers/scope.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)