Browse Source

Fixed shit before sleep

Toby Chui 1 year ago
parent
commit
8cbe4bf6a6
3 changed files with 34 additions and 47 deletions
  1. 3 3
      agi-doc.md
  2. 0 12
      mod/agi/userFunc.go
  3. 31 32
      web/UnitTest/backend/appdata.listDir.js

+ 3 - 3
agi-doc.md

@@ -370,9 +370,9 @@ USER_MODULES //Might return ["*"] for admin permission
 #### Filepath Virtualization
 
 ```
-decodeVirtualPath("user:/Desktop"); //Convert virtual path (e.g. user:/Desktop) to real path (e.g. ./files/user/username/Desktop)
-decodeAbsoluteVirtualPath("user:/Desktop"); //Same as decodeVirtualPath but return in absolute path instead of relative path from the arozos binary root
-encodeRealPath("files/users/User/Desktop"); //Convert realpath into virtual path
+[deprecated] decodeVirtualPath("user:/Desktop"); //Convert virtual path (e.g. user:/Desktop) to real path (e.g. ./files/user/username/Desktop)
+[deprecated] decodeAbsoluteVirtualPath("user:/Desktop"); //Same as decodeVirtualPath but return in absolute path instead of relative path from the arozos binary root
+[deprecated] encodeRealPath("files/users/User/Desktop"); //Convert realpath into virtual path
 ```
 
 #### Permission Related

+ 0 - 12
mod/agi/userFunc.go

@@ -202,18 +202,6 @@ func (g *Gateway) injectUserFunctions(vm *otto.Otto, fsh *filesystem.FileSystemH
 		}
 	})
 
-	vm.Set("getUserInfoByName", func(call otto.FunctionCall) otto.Value {
-		//libname, err := call.Argument(0).ToString()
-		if u.IsAdmin() {
-
-		} else {
-
-			g.RaiseError(errors.New("Permission Denied: getUserInfoByName require admin permission"))
-			return otto.FalseValue()
-		}
-		return otto.TrueValue()
-	})
-
 	//Allow real time library includsion into the virtual machine
 	vm.Set("requirelib", func(call otto.FunctionCall) otto.Value {
 		libname, err := call.Argument(0).ToString()

+ 31 - 32
web/UnitTest/backend/appdata.listDir.js

@@ -1,32 +1,31 @@
-/*
-    appdata.readFile.js
-
-    This script test the appdata read file function.
-    This should be able to read file 
-*/
-
-//Require the appdata library
-var succ = requirelib("appdata");
-
-function main(){
-    //List all files within the UnitTest backend example library
-    var backendExamples = appdata.listDir("UnitTest/backend/");
-
-    //Check if there are any error for reading the file
-    if (backendExamples == false){
-        sendJSONResp(JSON.stringify({
-            error: "Unable to list backend example library"
-        }));
-    }else{
-        //Success. Return the file list of the folder
-        sendJSONResp(backendExamples);
-    }
-}
-
-if (!succ){
-    //Library include failed.
-    sendResp("Include Appdata lib failed. Is your ArozOS version too old?")
-}else{
-    //Library include succeed. Start reading from webroot
-    main();
-}
+/*
+    appdata.listDir.js
+
+    This script test the appdata list dir function.
+*/
+
+//Require the appdata library
+var succ = requirelib("appdata");
+
+function main(){
+    //List all files within the UnitTest backend example library
+    var backendExamples = appdata.listDir("UnitTest/backend/");
+
+    //Check if there are any error for reading the file
+    if (backendExamples == false){
+        sendJSONResp(JSON.stringify({
+            error: "Unable to list backend example library"
+        }));
+    }else{
+        //Success. Return the file list of the folder
+        sendJSONResp(backendExamples);
+    }
+}
+
+if (!succ){
+    //Library include failed.
+    sendResp("Include Appdata lib failed. Is your ArozOS version too old?")
+}else{
+    //Library include succeed. Start reading from webroot
+    main();
+}