marinofaggiana 4 年之前
父节点
当前提交
e532856a74

+ 1 - 1
Cartfile.resolved

@@ -19,7 +19,7 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.6"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "b85e32823013e4b2048b5df6cc368986a7d75323"
+github "nextcloud/ios-communication-library" "12c7b1c191e24a6828234632572288c4ecb02125"
 github "realm/realm-cocoa" "v4.4.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.4"

+ 1 - 1
iOSClient/CCGlobal.h

@@ -84,7 +84,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         104
+#define k_databaseSchemaVersion                         105
 
 // Intro selector
 #define k_intro_login                                   0

+ 1 - 0
iOSClient/Database/NCDatabase.swift

@@ -174,6 +174,7 @@ class tableComments: Object {
     @objc dynamic var messageID = ""
     @objc dynamic var objectId = ""
     @objc dynamic var objectType = ""
+    @objc dynamic var path = ""
     @objc dynamic var verb = ""
     
     override static func primaryKey() -> String {

+ 17 - 18
iOSClient/Database/NCManageDatabase.swift

@@ -589,7 +589,7 @@ class NCManageDatabase: NSObject {
                 result.storageLocation = userProfile.storageLocation
                 result.subadmin = userProfile.subadmin.joined(separator: ",")
                 result.twitter = userProfile.twitter
-                result.userID = userProfile.userID
+                result.userID = userProfile.userId
                 result.webpage = userProfile.webpage
                 
                 returnAccount = result
@@ -973,8 +973,7 @@ class NCManageDatabase: NSObject {
     //MARK: -
     //MARK: Table Comments
     
-    #if !EXTENSION
-    @objc func addComments(_ listOfComments: [NCComments], account: String, objectId: String) {
+    @objc func addComments(_ comments: [NCCommunicationComments], account: String, objectId: String) {
         
         let realm = try! Realm()
         
@@ -984,30 +983,30 @@ class NCManageDatabase: NSObject {
                 let results = realm.objects(tableComments.self).filter("account == %@ AND objectId == %@", account, objectId)
                 realm.delete(results)
                 
-                for comment in listOfComments {
+                for comment in comments {
                     
-                    let addObject = tableComments()
+                    let object = tableComments()
                     
-                    addObject.account = account
-                    addObject.actorDisplayName = comment.actorDisplayName
-                    addObject.actorId = comment.actorId
-                    addObject.actorType = comment.actorType
-                    addObject.creationDateTime = comment.creationDateTime as NSDate
-                    addObject.isUnread = comment.isUnread
-                    addObject.message = comment.message
-                    addObject.messageID = comment.messageID
-                    addObject.objectId = comment.objectId
-                    addObject.objectType = comment.objectType
-                    addObject.verb = comment.verb
+                    object.account = account
+                    object.actorDisplayName = comment.actorDisplayName
+                    object.actorId = comment.actorId
+                    object.actorType = comment.actorType
+                    object.creationDateTime = comment.creationDateTime as NSDate
+                    object.isUnread = comment.isUnread
+                    object.message = comment.message
+                    object.messageID = comment.messageId
+                    object.objectId = comment.objectId
+                    object.objectType = comment.objectType
+                    object.path = comment.path
+                    object.verb = comment.verb
                     
-                    realm.add(addObject, update: .all)
+                    realm.add(object, update: .all)
                 }
             }
         } catch let error {
             print("[LOG] Could not write to database: ", error)
         }
     }
-    #endif
     
     @objc func getComments(account: String, objectId: String) -> [tableComments] {
         

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -463,7 +463,7 @@ import NCCommunication
                     for template in templates! {
                         
                         let temp = NCCommunicationEditorTemplates()
-                        temp.identifier = "\(template.templateID)"
+                        temp.identifier = "\(template.templateId)"
                         temp.delete = template.delete
                         temp.ext = template.ext
                         temp.name = template.name

+ 0 - 1
iOSClient/Networking/OCNetworking.h

@@ -54,7 +54,6 @@
 
 #pragma mark ===== Comments =====
 
-- (void)getCommentsWithAccount:(NSString *)account fileId:(NSString *)fileId completion:(void (^)(NSString *account, NSArray *items, NSString *message, NSInteger errorCode))completion;
 - (void)putCommentsWithAccount:(NSString *)account fileId:(NSString *)fileId message:(NSString *)message  completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 - (void)updateCommentsWithAccount:(NSString *)account fileId:(NSString *)fileId messageID:(NSString *)messageID message:(NSString *)message  completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 - (void)readMarkCommentsWithAccount:(NSString *)account fileId:(NSString *)fileId completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;

+ 0 - 38
iOSClient/Networking/OCNetworking.m

@@ -610,44 +610,6 @@
 #pragma mark ===== Comments =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)getCommentsWithAccount:(NSString *)account fileId:(NSString *)fileId completion:(void (^)(NSString *account, NSArray *items, NSString *message, NSInteger errorCode))completion
-{
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
-    if (tableAccount == nil) {
-        completion(account, nil, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
-    } else if ([CCUtility getPassword:account].length == 0) {
-        completion(account, nil, NSLocalizedString(@"_bad_username_password_", nil), kOCErrorServerUnauthorized);
-    } else if ([CCUtility getCertificateError:account]) {
-        completion(account, nil, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
-    }
-    
-    OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
-
-    [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
-    [communication setUserAgent:[CCUtility getUserAgent]];
-    
-    [communication getComments:[NSString stringWithFormat:@"%@%@", tableAccount.url, k_dav] fileId:fileId onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer) {
-        
-        completion(account, list, nil, 0);
-
-    } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
-        
-        NSString *message;
-        NSInteger errorCode = response.statusCode;
-        
-        if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
-            errorCode = error.code;
-        
-        // Error
-        if (errorCode == 503)
-            message = NSLocalizedString(@"_server_error_retry_", nil);
-        else
-            message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
-        
-        completion(account, nil,message, errorCode);
-    }];
-}
-
 - (void)putCommentsWithAccount:(NSString *)account fileId:(NSString *)fileId message:(NSString *)message  completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
 {
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];

+ 5 - 6
iOSClient/Share/NCShareComments.swift

@@ -104,15 +104,14 @@ class NCShareComments: UIViewController, NCShareCommentsCellDelegate {
         
         guard let metadata = self.metadata else { return }
 
-        OCNetworking.sharedManager()?.getCommentsWithAccount(appDelegate.activeAccount, fileId: metadata.fileId, completion: { (account, items, message, errorCode) in
-            if errorCode == 0 {
-                let itemsNCComments = items as! [NCComments]
-                NCManageDatabase.sharedInstance.addComments(itemsNCComments, account: metadata.account, objectId: metadata.fileId)
+        NCCommunication.shared.getComments(fileId: metadata.fileId, customUserAgent: nil, addCustomHeaders: nil, account: appDelegate.activeAccount) { (account, comments, errorCode, errorDescription) in
+            if errorCode == 0 && comments != nil {
+                NCManageDatabase.sharedInstance.addComments(comments!, account: metadata.account, objectId: metadata.fileId)
                 self.tableView.reloadData()
             } else {
-               NCContentPresenter.shared.messageNotification("_share_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+               NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
             }
-        })
+        }
         
         tableView.reloadData()
     }