Преглед изворни кода

Optimized share API endpoint responses

Toby Chui пре 3 година
родитељ
комит
d4724d8be5
3 измењених фајлова са 25 додато и 3 уклоњено
  1. 19 0
      mod/share/share.go
  2. 4 1
      web/SystemAO/locale/desktop.json
  3. 2 2
      web/desktop.system

+ 19 - 0
mod/share/share.go

@@ -120,6 +120,25 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 				}
 			} else if subpathElements[1] == "preview" {
 				directServe = true
+			} else if len(subpathElements) == 3 {
+				//Check if the last element is the filename
+				if strings.Contains(subpathElements[2], ".") {
+					//Share link contain filename. Redirect to share interface
+					http.Redirect(w, r, "./", http.StatusTemporaryRedirect)
+					return
+				} else {
+					//Incorrect operation type
+					w.WriteHeader(http.StatusBadRequest)
+					w.Header().Set("Content-Type", "text/plain") // this
+					w.Write([]byte("400 - Operation type not supported: " + subpathElements[1]))
+					return
+				}
+			} else if len(subpathElements) >= 4 {
+				//Invalid operation type
+				w.WriteHeader(http.StatusBadRequest)
+				w.Header().Set("Content-Type", "text/plain") // this
+				w.Write([]byte("400 - Operation type not supported: " + subpathElements[1]))
+				return
 			}
 		} else if len(subpathElements) == 1 {
 			//ID is missing. Serve the id input page

+ 4 - 1
web/SystemAO/locale/desktop.json

@@ -67,6 +67,7 @@
                 "contextmenu/Select Other WebApps": "選擇預設應用程式",
                 "contextmenu/Open Shared Link": "開啟分享鏈接",
                 "contextmenu/Copy Link": "複製鏈接",
+                "contextmenu/Copied": "已複製",
                 "contextmenu/Change Share Settings": "更改分享設定",
                 "contextmenu/Share this File": "分享此檔案",
                 "contextmenu/share/link": "任何擁有鏈接的使用者",
@@ -158,6 +159,7 @@
                 "contextmenu/Select Other WebApps": "選擇預設應用程式",
                 "contextmenu/Open Shared Link": "開啟分享鏈接",
                 "contextmenu/Copy Link": "複製鏈接",
+                "contextmenu/Copied": "已複製",
                 "contextmenu/Change Share Settings": "更改分享設定",
                 "contextmenu/Share this File": "分享此檔案",
                 "contextmenu/share/link": "任何擁有鏈接的使用者",
@@ -249,7 +251,8 @@
                 "contextmenu/Close": "关闭",
                 "contextmenu/Select Other WebApps": "选择预设应用程序",
                 "contextmenu/Open Shared Link": "打开分享连接",
-                "contextmenu/Copy Link": "复制链接",
+                "contextmenu/Copy Link": "拷贝链接",
+                "contextmenu/Copied": "已拷贝",
                 "contextmenu/Change Share Settings": "更改分享设置",
                 "contextmenu/Share this File": "分享此文件",
                 "contextmenu/share/link": "任何拥有连接的使用者",

+ 2 - 2
web/desktop.system

@@ -4762,10 +4762,10 @@
             document.body.removeChild(area);
 
             //Update status so it show the user it has been coped
-            $(target).html(`<i style="color: #71ba68;" class="checkmark icon"></i> Copied!`);
+            $(target).html(`<i style="color: #71ba68;" class="checkmark icon"></i> ${lcontex("Copied")}`);
             setTimeout(function(){
                 if ($(target).length > 0){
-                    $(target).html(`Copy Link
+                    $(target).html(`${lcontex("Copy Link")}
                         <span class="description">
                             <i class="copy icon"></i>
                         </span>`);