Skip to content

Commit

Permalink
Fixed public link paths in wopi driver following frontend updates
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Feb 24, 2023
1 parent 019b352 commit 85c1130
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import (
"github.com/pkg/errors"
)

const publicLinkUrlPrefix = "/files/link/public/"

func init() {
registry.Register("wopi", New)
}
Expand Down Expand Up @@ -166,7 +168,7 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc

// TODO (lopresti) consolidate with the templating implemented in the edge branch;
// here we assume the FolderBaseURL looks like `https://<hostname>` and we
// either append `/files/spaces/<full_path>` or `/s/<pltoken>/<relative_path>`
// either append `/files/spaces/<full_path>` or publicLinkUrlPrefix + `/<relative_path>`
var rPath string
if _, ok := utils.HasPublicShareRole(u); ok {
// we are in a public link
Expand Down Expand Up @@ -494,7 +496,7 @@ func getPathForPublicLink(ctx context.Context, scopes map[string]*authpb.Scope,

if statRes.Info.Path == resource.Path {
// this is a direct link to the resource
return "/s/" + pubShares[0].Token, nil
return publicLinkUrlPrefix + pubShares[0].Token, nil
}
// otherwise we are in a subfolder of the public link
relPath, err := filepath.Rel(statRes.Info.Path, resource.Path)
Expand All @@ -504,5 +506,5 @@ func getPathForPublicLink(ctx context.Context, scopes map[string]*authpb.Scope,
if strings.HasPrefix(relPath, "../") {
return "", errors.New("Scope path does not contain target resource")
}
return path.Join("/files/public/show/"+pubShares[0].Token, path.Dir(relPath)), nil
return path.Join(publicLinkUrlPrefix+pubShares[0].Token, path.Dir(relPath)), nil
}

0 comments on commit 85c1130

Please sign in to comment.