From c059dec2528db52668fc9554e07a8f665a87d491 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Tue, 29 Mar 2022 14:39:30 +0200 Subject: [PATCH] Support editnew actions from MS Office --- pkg/app/provider/wopi/wopi.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/app/provider/wopi/wopi.go b/pkg/app/provider/wopi/wopi.go index 0a9b2fd1872..c508384758f 100644 --- a/pkg/app/provider/wopi/wopi.go +++ b/pkg/app/provider/wopi/wopi.go @@ -165,13 +165,19 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc q.Add("appviewurl", viewAppURL) } } - if editAppURLs, ok := p.appURLs["edit"]; ok { + var access string = "edit" + if resource.GetSize() == 0 { + if _, ok := p.appURLs["editnew"]; ok { + access = "editnew" + } + } + if editAppURLs, ok := p.appURLs[access]; 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 + // assuming that a 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 @@ -371,7 +377,7 @@ func parseWopiDiscovery(body io.Reader) (map[string]map[string]string, error) { for _, app := range netzone.SelectElements("app") { for _, action := range app.SelectElements("action") { access := action.SelectAttrValue("name", "") - if access == "view" || access == "edit" { + if access == "view" || access == "edit" || access == "editnew" { ext := action.SelectAttrValue("ext", "") urlString := action.SelectAttrValue("urlsrc", "")