From fe381b43c2867e13e1e20c577b62e71958affecd Mon Sep 17 00:00:00 2001 From: DrosoCode Date: Mon, 31 May 2021 14:29:17 +0200 Subject: [PATCH] fix: formatting --- frontend/src/views/Files.vue | 4 +--- frontend/src/views/files/OnlyOfficeEditor.vue | 19 ++++++++------- http/onlyoffice.go | 24 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/frontend/src/views/Files.vue b/frontend/src/views/Files.vue index 8a547313..69ce635f 100644 --- a/frontend/src/views/Files.vue +++ b/frontend/src/views/Files.vue @@ -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"; diff --git a/frontend/src/views/files/OnlyOfficeEditor.vue b/frontend/src/views/files/OnlyOfficeEditor.vue index 22bd0444..bfdb2b36 100644 --- a/frontend/src/views/files/OnlyOfficeEditor.vue +++ b/frontend/src/views/files/OnlyOfficeEditor.vue @@ -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() { diff --git a/http/onlyoffice.go b/http/onlyoffice.go index c8bc67da..054ed0f5 100644 --- a/http/onlyoffice.go +++ b/http/onlyoffice.go @@ -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 }