Browse Source

Fix

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 year ago
parent
commit
bb1d86e788

+ 15 - 13
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -198,19 +198,6 @@ extension tableMetadata {
         return directory && size == 0 && !e2eEncrypted && CCUtility.isEnd(toEndEnabled: account)
     }
 
-    var isSharable: Bool {
-        let sharing = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-        if !sharing { return false }
-        if !e2eEncrypted && !isDirectoryE2EE { return true }
-        let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-        if serverVersionMajor >= NCGlobal.shared.nextcloudVersion26 && directory {
-            // E2EE DIRECTORY SECURE FILE DROP (SHARE AVAILABLE)
-            return true
-        } else {
-            return false
-        }
-    }
-
     var isDirectoryUnsettableE2EE: Bool {
         return !isDirectoryE2EE && directory && size == 0 && e2eEncrypted && CCUtility.isEnd(toEndEnabled: account)
     }
@@ -246,6 +233,21 @@ extension tableMetadata {
     func canUnlock(as user: String) -> Bool {
         return !lock || (lockOwner == user && lockOwnerType == 0)
     }
+
+    /// Return if is sharable (temp)
+    // TODO: modifify for E2EE 2.0
+    func isSharable(sharing: Bool, serverVersion: Int) -> Bool {
+        guard sharing else { return false }
+
+        if !e2eEncrypted && !isDirectoryE2EE {
+            return true
+        } else if serverVersion >= NCGlobal.shared.nextcloudVersion26 && directory {
+            // E2EE DIRECTORY SECURE FILE DROP (SHARE AVAILABLE)
+            return true
+        } else {
+            return false
+        }
+    }
 }
 
 extension NCManageDatabase {

+ 8 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -67,6 +67,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     private var tipView: EasyTipView?
 
+    private var sharing: Bool = true
+    private var serverVersion: Int = 0
+
     // DECLARE
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
@@ -165,6 +168,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         appDelegate.activeViewController = self
 
+        sharing = NCManageDatabase.shared.getCapabilitiesServerBool(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
+        serverVersion = NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+
         layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: serverUrl)
         gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
         if layoutForView?.layout == NCGlobal.shared.layoutList {
@@ -1658,7 +1664,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
         // ** IMPORT MUST BE AT THE END **
         //
-        if !metadata.isSharable {
+
+        if !metadata.isSharable(sharing: sharing, serverVersion: serverVersion) {
             cell.hideButtonShare(true)
         }
         

+ 3 - 1
iOSClient/Main/NCActionCenter.swift

@@ -191,6 +191,8 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
     func openShare(viewController: UIViewController, metadata: tableMetadata, page: NCBrandOptions.NCInfoPagingTab) {
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
+        let sharing = NCManageDatabase.shared.getCapabilitiesServerBool(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
+        let serverVersion = NCManageDatabase.shared.getCapabilitiesServerInt(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
         var page = page
 
         NCActivityIndicator.shared.start(backgroundView: viewController.view)
@@ -213,7 +215,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                 if activity == nil, let idx = pages.firstIndex(of: .activity) {
                     pages.remove(at: idx)
                 }
-                if !metadata.isSharable, let idx = pages.firstIndex(of: .sharing) {
+                if !metadata.isSharable(sharing: sharing, serverVersion: serverVersion), let idx = pages.firstIndex(of: .sharing) {
                     pages.remove(at: idx)
                 }
                 (pages, page) = NCApplicationHandle().filterPages(pages: pages, page: page, metadata: metadata)