fix: formatting

This commit is contained in:
DrosoCode 2021-05-31 14:29:17 +02:00
parent b0c038174a
commit fe381b43c2
3 changed files with 23 additions and 24 deletions

View File

@ -65,9 +65,7 @@ export default {
this.req.type === "textImmutable" this.req.type === "textImmutable"
) { ) {
return "editor"; return "editor";
} else if ( } else if (this.req.type === "officedocument" && onlyOffice !== "") {
this.req.type === "officedocument" && onlyOffice !== ""
) {
return "OnlyOfficeEditor"; return "OnlyOfficeEditor";
} else { } else {
return "preview"; return "preview";

View File

@ -85,14 +85,15 @@ export default {
document.head.appendChild(onlyofficeScript); document.head.appendChild(onlyofficeScript);
onlyofficeScript.onload = () => { onlyofficeScript.onload = () => {
let fileUrl = `${window.location.protocol}//${window.location.host}${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${ let fileUrl = `${window.location.protocol}//
this.jwt ${window.location.host}${baseURL}/api/raw${url.encodePath(
}`; this.req.path
)}?auth=${this.jwt}`;
let key = Date.parse(this.req.modified).toString() + this.req.path let key = Date.parse(this.req.modified).toString() + this.req.path;
key = key.replaceAll(/[-_.!~[\]*'()/,;:\-%+.]/g, "") key = key.replaceAll(/[-_.!~[\]*'()/,;:\-%+.]/g, "");
if (key.length > 127) { if (key.length > 127) {
key = key.substring(0, 127) key = key.substring(0, 127);
} }
/*eslint-disable */ /*eslint-disable */
@ -121,10 +122,10 @@ export default {
lang: this.user.locale, lang: this.user.locale,
mode: this.user.perm.modify ? "edit" : "view" mode: this.user.perm.modify ? "edit" : "view"
} }
} };
this.editor = new DocsAPI.DocEditor("editor", config); this.editor = new DocsAPI.DocEditor("editor", config);
/*eslint-enable */ /*eslint-enable */
} };
}, },
methods: { methods: {
back() { back() {

View File

@ -1,17 +1,17 @@
package http package http
import ( import (
"encoding/json"
"errors"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"errors"
"encoding/json"
) )
type OnlyOfficeCallback struct { type OnlyOfficeCallback struct {
ChangesUrl string `json:"changesurl,omitempty"` ChangesURL string `json:"changesurl,omitempty"`
Key string `json:"key"` Key string `json:"key"`
Status int `json:"status"` Status int `json:"status"`
Url string `json:"url,omitempty"` URL string `json:"url,omitempty"`
Users []string `json:"users,omitempty"` Users []string `json:"users,omitempty"`
UserData string `json:"userdata,omitempty"` UserData string `json:"userdata,omitempty"`
} }
@ -28,17 +28,17 @@ var onlyofficeCallbackHandler = withUser(func(w http.ResponseWriter, r *http.Req
return http.StatusInternalServerError, err1 return http.StatusInternalServerError, err1
} }
if (data.Status == 2 || data.Status == 6) { if data.Status == 2 || data.Status == 6 {
docPath := r.URL.Query().Get("save") docPath := r.URL.Query().Get("save")
if docPath == "" { if docPath == "" {
return http.StatusInternalServerError, errors.New("Unable to get file save path") return http.StatusInternalServerError, errors.New("unable to get file save path")
} }
if !d.user.Perm.Modify || !d.Check(docPath) { if !d.user.Perm.Modify || !d.Check(docPath) {
return http.StatusForbidden, nil return http.StatusForbidden, nil
} }
doc, err2 := http.Get(data.Url) doc, err2 := http.Get(data.URL)
if err2 != nil { if err2 != nil {
return http.StatusInternalServerError, err2 return http.StatusInternalServerError, err2
} }