Skip to content

Commit

Permalink
Fix opening a readonly filetype with WOPI (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek authored Sep 27, 2021
1 parent 9928277 commit 83a8848
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-wopi-readonly-filetype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix opening a readonly filetype with WOPI

This change fixes the opening of filetypes that
are only supported to be viewed and not to be edited
by some WOPI compliant office suites.

https://github.com/cs3org/reva/pull/2073
29 changes: 23 additions & 6 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,33 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc
}

q.Add("appname", p.conf.AppName)
q.Add("appurl", p.appURLs["edit"][ext])

if p.conf.AppIntURL != "" {
q.Add("appinturl", p.conf.AppIntURL)
var viewAppURL string
if viewAppURLs, ok := p.appURLs["view"]; ok {
if viewAppURL, ok = viewAppURLs[ext]; ok {
q.Add("appviewurl", viewAppURL)
}
}
if viewExts, ok := p.appURLs["view"]; ok {
if url, ok := viewExts[ext]; ok {
q.Add("appviewurl", url)
if editAppURLs, ok := p.appURLs["edit"]; ok {
if editAppURL, ok := editAppURLs[ext]; ok {
q.Add("appurl", editAppURL)
}
}
if q.Get("appurl") == "" {
// assuming that an view action is always available in the /hosting/discovery manifest
// eg. Collabora does support viewing jpgs but no editing
// eg. OnlyOffice does support viewing pdfs but no editing
// there is no known case of supporting edit only without view
q.Add("appurl", viewAppURL)
}
if q.Get("appurl") == "" && q.Get("appviewurl") == "" {
return nil, errors.New("wopi: neither edit nor view app url found")
}

if p.conf.AppIntURL != "" {
q.Add("appinturl", p.conf.AppIntURL)
}

httpReq.URL.RawQuery = q.Encode()

if p.conf.AppAPIKey != "" {
Expand Down

0 comments on commit 83a8848

Please sign in to comment.