|
|
@ -58,7 +58,7 @@ const (
|
|
|
|
MethodRename = "RENAME_FILE"
|
|
|
|
MethodRename = "RENAME_FILE"
|
|
|
|
|
|
|
|
|
|
|
|
wopiSrcPlaceholder = "WOPI_SOURCE"
|
|
|
|
wopiSrcPlaceholder = "WOPI_SOURCE"
|
|
|
|
wopiSrcParamDefault = "wopisrc"
|
|
|
|
wopiSrcParamDefault = "WOPISrc"
|
|
|
|
sessionExpiresPadding = 10
|
|
|
|
sessionExpiresPadding = 10
|
|
|
|
wopiHeaderPrefix = "X-WOPI-"
|
|
|
|
wopiHeaderPrefix = "X-WOPI-"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -67,6 +67,9 @@ const (
|
|
|
|
func Init() {
|
|
|
|
func Init() {
|
|
|
|
settings := model.GetSettingByNames("wopi_endpoint", "wopi_enabled")
|
|
|
|
settings := model.GetSettingByNames("wopi_endpoint", "wopi_enabled")
|
|
|
|
if !model.IsTrueVal(settings["wopi_enabled"]) {
|
|
|
|
if !model.IsTrueVal(settings["wopi_enabled"]) {
|
|
|
|
|
|
|
|
DefaultMu.Lock()
|
|
|
|
|
|
|
|
Default = nil
|
|
|
|
|
|
|
|
DefaultMu.Unlock()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -126,14 +129,20 @@ func (c *client) NewSession(user *model.User, file *model.File, action ActonType
|
|
|
|
return nil, ErrActionNotSupported
|
|
|
|
return nil, ErrActionNotSupported
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
actionConfig, ok := availableActions[string(action)]
|
|
|
|
var (
|
|
|
|
if !ok {
|
|
|
|
actionConfig Action
|
|
|
|
// Preferred action not available, fallback to view only action
|
|
|
|
)
|
|
|
|
if actionConfig, ok = availableActions[string(ActionPreview)]; !ok {
|
|
|
|
fallbackOrder := []ActonType{action, ActionPreview, ActionPreviewFallback, ActionEdit}
|
|
|
|
return nil, ErrActionNotSupported
|
|
|
|
for _, a := range fallbackOrder {
|
|
|
|
|
|
|
|
if actionConfig, ok = availableActions[string(a)]; ok {
|
|
|
|
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if actionConfig.Urlsrc == "" {
|
|
|
|
|
|
|
|
return nil, ErrActionNotSupported
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Generate WOPI REST endpoint for given file
|
|
|
|
// Generate WOPI REST endpoint for given file
|
|
|
|
baseURL := model.GetSiteURL()
|
|
|
|
baseURL := model.GetSiteURL()
|
|
|
|
linkPath, err := url.Parse(fmt.Sprintf("/api/v3/wopi/files/%s", hashid.HashID(file.ID, hashid.FileID)))
|
|
|
|
linkPath, err := url.Parse(fmt.Sprintf("/api/v3/wopi/files/%s", hashid.HashID(file.ID, hashid.FileID)))
|
|
|
|