marinofaggiana 5 жил өмнө
parent
commit
d9ed9bfee8

+ 11 - 9
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -3197,7 +3197,7 @@
 
 
 - (void)getComments:(NSString *)serverPath fileID:(NSString *)fileID onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
 - (void)getComments:(NSString *)serverPath fileID:(NSString *)fileID onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
     
-    serverPath = [NSString stringWithFormat:@"%@/comments/files/%@?format=json", serverPath, fileID];
+    serverPath = [NSString stringWithFormat:@"%@/comments/files/%@", serverPath, fileID];
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
 
 
     OCWebDAVClient *request = [OCWebDAVClient new];
     OCWebDAVClient *request = [OCWebDAVClient new];
@@ -3205,14 +3205,16 @@
     
     
     [request getComments:serverPath onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
     [request getComments:serverPath onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
         
         
-        NSData *responseData = (NSData*) response;
+        if (successRequest) {
-        
+            NSData *responseData = (NSData*) responseObject;
-        //Parse
+            
-        //NSError *error;
+            OCXMLParser *parser = [[OCXMLParser alloc]init];
-        //NSDictionary *jsongParsed = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
+            [parser initParserWithData:responseData];
-        //NSLog(@"[LOG] URL Asset : %@",jsongParsed);
+            NSMutableArray *directoryList = [parser.directoryList mutableCopy];
-
+            
-        successRequest(response, nil, request.redirectedServer);
+            //Return success
+            successRequest(response, directoryList, request.redirectedServer);
+        }
         
         
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error) {
     } failure:^(NSHTTPURLResponse *response, id responseData, NSError *error) {
         
         

+ 7 - 8
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -1492,14 +1492,13 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     _requestMethod = @"PROPFIND";
     _requestMethod = @"PROPFIND";
     
     
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil timeout:k_timeout_webdav];
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil timeout:k_timeout_webdav];
-    [request setValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
+                          
-    
+    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><d:propfind xmlns:d=\"DAV:\">"
-    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
+                         "<d:prop xmlns:oc=\"http://owncloud.org/ns\">"
-                         "<D:prop>"
+                         "<oc:message/>"
-                         "<D:actorId/>"
+                         "</d:prop>"
-                         "</D:prop>"
+                         "</d:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
-                         "</D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
+    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
-    [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
     
     
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];

+ 1 - 1
iOSClient/Networking/OCNetworking.m

@@ -2725,7 +2725,7 @@
     [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
     [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
     [communication setUserAgent:[CCUtility getUserAgent]];
     [communication setUserAgent:[CCUtility getUserAgent]];
     
     
-    [communication getComments:[NSString stringWithFormat:@"%@%@", tableAccount.url, k_dav] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer) {
+    [communication getComments:[NSString stringWithFormat:@"%@%@", tableAccount.url, k_dav] fileID:[[NCUtility sharedInstance] convertLocalFileID:fileID] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *list, NSString *redirectedServer) {
         
         
         completion(account, list, nil, 0);
         completion(account, list, nil, 0);
 
 

+ 12 - 0
iOSClient/Utility/NCUtility.swift

@@ -394,5 +394,17 @@ class NCUtility: NSObject {
         
         
         CCUtility.deleteAllChainStore()
         CCUtility.deleteAllChainStore()
     }
     }
+    
+    @objc func convertLocalFileID(_ fileID:String) -> String {
+        
+        var localFileID = fileID
+        
+        if let endIndex = fileID.range(of: "oc")?.lowerBound {
+            let id = Int(fileID[..<endIndex])
+            localFileID = String(id ?? 0)
+        }
+        
+        return localFileID
+    }
 }
 }