Prechádzať zdrojové kódy

https://github.com/nextcloud/ios/issues/2335

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 rokov pred
rodič
commit
69fb7411af

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

@@ -177,6 +177,19 @@ 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)
     }

+ 2 - 4
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1682,13 +1682,11 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         }
 
         // ** IMPORT MUST BE AT THE END **
-        // if metadata.e2eEncrypted || isDirectoryE2EE {
         //
-        // E2EE SECURE FILE DROP (DIR ONLY)
-        if !metadata.directory && (metadata.e2eEncrypted || isDirectoryE2EE) {
+        if !metadata.isSharable {
             cell.hideButtonShare(true)
         }
-
+        
         return cell
     }
 

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -110,6 +110,7 @@ class NCGlobal: NSObject {
     let nextcloudVersion23: Int                     =  23
     let nextcloudVersion24: Int                     =  24
     let nextcloudVersion25: Int                     =  25
+    let nextcloudVersion26: Int                     =  26
 
     // Database Realm
     //

+ 3 - 2
iOSClient/Share/NCSharePaging.swift

@@ -54,7 +54,9 @@ class NCSharePaging: UIViewController {
         navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_close_", comment: ""), style: .done, target: self, action: #selector(exitTapped))
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
+
         setupCapabilities()
+
         // *** MUST BE THE FIRST ONE ***
         pagingViewController.metadata = metadata
 
@@ -111,8 +113,7 @@ class NCSharePaging: UIViewController {
         if serverVersionMajor >= NCGlobal.shared.nextcloudVersion20 && comments == false {
             commentsEnabled = false
         }
-        let sharing = NCManageDatabase.shared.getCapabilitiesServerBool(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-        sharingEnabled = sharing
+        sharingEnabled = metadata.isSharable
         let activity = NCManageDatabase.shared.getCapabilitiesServerArray(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesActivity)
         activityEnabled = activity != nil
         if indexPage == .sharing && !sharingEnabled {