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"
) {
return "editor";
} else if (
this.req.type === "officedocument" && onlyOffice !== ""
) {
} else if (this.req.type === "officedocument" && onlyOffice !== "") {
return "OnlyOfficeEditor";
} else {
return "preview";

View File

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

View File

@ -1,19 +1,19 @@
package http
import (
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"errors"
"encoding/json"
)
type OnlyOfficeCallback struct {
ChangesUrl string `json:"changesurl,omitempty"`
Key string `json:"key"`
Status int `json:"status"`
Url string `json:"url,omitempty"`
Users []string `json:"users,omitempty"`
UserData string `json:"userdata,omitempty"`
ChangesURL string `json:"changesurl,omitempty"`
Key string `json:"key"`
Status int `json:"status"`
URL string `json:"url,omitempty"`
Users []string `json:"users,omitempty"`
UserData string `json:"userdata,omitempty"`
}
var onlyofficeCallbackHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
@ -28,17 +28,17 @@ var onlyofficeCallbackHandler = withUser(func(w http.ResponseWriter, r *http.Req
return http.StatusInternalServerError, err1
}
if (data.Status == 2 || data.Status == 6) {
if data.Status == 2 || data.Status == 6 {
docPath := r.URL.Query().Get("save")
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) {
return http.StatusForbidden, nil
}
doc, err2 := http.Get(data.Url)
doc, err2 := http.Get(data.URL)
if err2 != nil {
return http.StatusInternalServerError, err2
}