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 e17c730
Showing 1 changed file with 11 additions and 4 deletions.
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 e17c730

Please sign in to comment.