Skip to content

Commit

Permalink
Merge pull request #10757 from 2403905/issue-e7004-2
Browse files Browse the repository at this point in the history
Made GetScopeByKeyPrefix function as a private method of the FileConnector
  • Loading branch information
2403905 authored Dec 10, 2024
2 parents ffe56db + 8d1f990 commit fac368a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-onlyoffice-file-location-upd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix FileInfo BreadcrumbFolderURL upd

Made GetScopeByKeyPrefix function as a private method of the FileConnector

https://github.com/owncloud/ocis/pull/10757
19 changes: 18 additions & 1 deletion services/collaboration/pkg/connector/fileconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"encoding/base64"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"net/url"
"path"
"strings"
"time"

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

return newStatRes.GetInfo(), nil
}

// getScopeByKeyPrefix returns the scope from the AccessToken Scope map by key prefix
func (f *FileConnector) getScopeByKeyPrefix(scopes map[string]*auth.Scope, keyPrefix string, m proto.Message) error {
for k, v := range scopes {
if strings.HasPrefix(k, keyPrefix) && v.Resource.Decoder == "json" {
err := utils.UnmarshalJSONToProtoV1(v.Resource.Value, m)
if err != nil {
return fmt.Errorf("can't unmarshal public share from scope: %w", err)
}
return nil
}
}
return fmt.Errorf("scope %s not found", keyPrefix)
}
24 changes: 0 additions & 24 deletions services/collaboration/pkg/helpers/scope.go

This file was deleted.

0 comments on commit fac368a

Please sign in to comment.