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

Fixed minor bug in share permission check api in AGI gateway

tobychui пре 3 година
родитељ
комит
870527f7cc
3 измењених фајлова са 6 додато и 2 уклоњено
  1. 1 0
      AGI Documentation.md
  2. 4 2
      mod/agi/agi.share.go
  3. 1 0
      web/UnitTest/backend/share.shareFile.js

+ 1 - 0
AGI Documentation.md

@@ -759,6 +759,7 @@ share.shareFile("user:/Desktop/test.pptx", 300); //File virtual path and timeout
 share.getFileShareUUID("user:/Desktop/test.pptx"); //Get the share UUID of a given file, return null if not shared
 share.fileIsShared("user:/Desktop/test.pptx"); //Return true / false
 share.checkShareExists(shareUUID); //Return true / false
+share.checkSharePermission(shareUUID); //Return the share permission of shares (anyone / signedin / samegroup), return null if shareUUID invalid.
 share.removeShare(shareUUID);
 ```
 

+ 4 - 2
mod/agi/agi.share.go

@@ -116,8 +116,10 @@ func (g *Gateway) injectShareFunctions(vm *otto.Otto, u *user.User) {
 		}
 
 		shareObject := g.Option.ShareManager.GetShareObjectFromUUID(shareUUID)
-
-		r, _ := otto.ToValue(shareObject.Accessibles)
+		if shareObject == nil {
+			return otto.NullValue()
+		}
+		r, _ := otto.ToValue(shareObject.Permission)
 		return r
 	})
 

+ 1 - 0
web/UnitTest/backend/share.shareFile.js

@@ -19,6 +19,7 @@ function main(){
         //Check if the source file is shared
         console.log("Source file is shared: " + share.fileIsShared("user:/Desktop/test.pptx"));
 
+        console.log("Source file share permission: " + share.checkSharePermission(shareUUID));
         //Remove the share using UUID
         //share.removeShare(shareUUID);