Merge pull request #4376 from wkloucek/open-with-web-endpoitn

[full-ci] add open-with-web endpoint
This commit is contained in:
Willy Kloucek
2022-08-18 10:21:01 +02:00
committed by GitHub
7 changed files with 97 additions and 12 deletions
+4 -1
View File
@@ -48,7 +48,10 @@ func Server(cfg *config.Config) *cli.Command {
pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid")
rcfg := revaconfig.FrontendConfigFromStruct(cfg)
rcfg, err := revaconfig.FrontendConfigFromStruct(cfg)
if err != nil {
return err
}
gr.Add(func() error {
runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger))
+29 -7
View File
@@ -1,6 +1,7 @@
package revaconfig
import (
"net/url"
"path"
"strconv"
@@ -9,7 +10,15 @@ import (
)
// FrontendConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} {
func FrontendConfigFromStruct(cfg *config.Config) (map[string]interface{}, error) {
webURL, err := url.Parse(cfg.PublicURL)
if err != nil {
return nil, err
}
webURL.Path = path.Join(webURL.Path, "external")
webOpenInAppURL := webURL.String()
archivers := []map[string]interface{}{
{
"enabled": true,
@@ -23,11 +32,12 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} {
appProviders := []map[string]interface{}{
{
"enabled": true,
"version": "1.0.0",
"apps_url": "/app/list",
"open_url": "/app/open",
"new_url": "/app/new",
"enabled": true,
"version": "1.1.0",
"apps_url": "/app/list",
"open_url": "/app/open",
"open_web_url": "/app/open-with-web",
"new_url": "/app/new",
},
}
@@ -88,6 +98,18 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} {
"transfer_shared_secret": cfg.TransferSecret,
"timeout": 86400,
"insecure": cfg.AppHandler.Insecure,
"webbaseuri": webOpenInAppURL,
"web": map[string]interface{}{
"urlparamsmapping": map[string]string{
// param -> value mapper
// these mappers are static and are only subject to change when changed in oC Web
"fileId": "fileid",
"app": "appname",
},
"staticurlparams": map[string]string{
"contextRouteName": "files-spaces-personal", // TODO: remove when https://github.com/owncloud/web/pull/7437 arrived in oCIS
},
},
},
"archiver": map[string]interface{}{
"prefix": cfg.Archiver.Prefix,
@@ -227,5 +249,5 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} {
},
},
},
}
}, nil
}