Skip to content

Commit

Permalink
improve the wopi app driver
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Sep 29, 2022
1 parent f298394 commit fb28bb6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/wopi-driver-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: The wopi app driver supports more options

We now generate a folderurl that is used in the wopi protocol to provide an endpoint to go back from the app to the containing folder in the file list. In addition to that we now inlclude the UI_LLCC parameter in the app open URL.

https://github.com/cs3org/reva/pull/3290
https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/discovery#ui_llcc
15 changes: 11 additions & 4 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func init() {
type config struct {
IOPSecret string `mapstructure:"iop_secret" docs:";The IOP secret used to connect to the wopiserver."`
WopiURL string `mapstructure:"wopi_url" docs:";The wopiserver's URL."`
PrivateLinkBaseURL string `mapstructure:"private_link_base_url" docs:";The base URL to generate private links to navigate back from apps."`
AppName string `mapstructure:"app_name" docs:";The App user-friendly name."`
AppIconURI string `mapstructure:"app_icon_uri" docs:";A URI to a static asset which represents the app icon."`
AppURL string `mapstructure:"app_url" docs:";The App URL."`
Expand Down Expand Up @@ -140,6 +141,13 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc
q.Add("fileid", resource.GetId().OpaqueId)
q.Add("viewmode", viewMode.String())

privateLinkBaseURl, err := url.Parse(p.conf.PrivateLinkBaseURL)
if err != nil {
return nil, err
}
privateLinkBaseURl.Path = path.Join(privateLinkBaseURl.Path, "f", storagespace.FormatResourceID(*resource.GetId()))
q.Add("folderurl", privateLinkBaseURl.String())

u, ok := ctxpkg.ContextGetUser(ctx)
if ok { // else defaults to "Guest xyz"
if u.Id.Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT || u.Id.Type == userpb.UserType_USER_TYPE_FEDERATED {
Expand Down Expand Up @@ -242,10 +250,9 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc
return nil, err
}
urlQuery := url.Query()
// we could improve this by using the UI_LLCC value from the wopi discovery url
// https://docs.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/discovery#ui_llcc
urlQuery.Set("ui", language) // OnlyOffice
urlQuery.Set("lang", language) // Collabora
urlQuery.Set("ui", language) // OnlyOffice
urlQuery.Set("lang", language) // Collabora
urlQuery.Set("UI_LLCC", language) // Office365
url.RawQuery = urlQuery.Encode()
appFullURL = url.String()
}
Expand Down

0 comments on commit fb28bb6

Please sign in to comment.