Procházet zdrojové kódy

dev new view share

marinofaggiana před 5 roky
rodič
revize
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 {
     
-    serverPath = [NSString stringWithFormat:@"%@/comments/files/%@?format=json", serverPath, fileID];
+    serverPath = [NSString stringWithFormat:@"%@/comments/files/%@", serverPath, fileID];
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
 
     OCWebDAVClient *request = [OCWebDAVClient new];
@@ -3205,14 +3205,16 @@
     
     [request getComments:serverPath onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
         
-        NSData *responseData = (NSData*) response;
-        
-        //Parse
-        //NSError *error;
-        //NSDictionary *jsongParsed = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
-        //NSLog(@"[LOG] URL Asset : %@",jsongParsed);
-
-        successRequest(response, nil, request.redirectedServer);
+        if (successRequest) {
+            NSData *responseData = (NSData*) responseObject;
+            
+            OCXMLParser *parser = [[OCXMLParser alloc]init];
+            [parser initParserWithData:responseData];
+            NSMutableArray *directoryList = [parser.directoryList mutableCopy];
+            
+            //Return success
+            successRequest(response, directoryList, request.redirectedServer);
+        }
         
     } 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";
     
     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:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">"
-                         "<D:prop>"
-                         "<D:actorId/>"
-                         "</D:prop>"
-                         "</D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
-    [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
+                          
+    [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><d:propfind xmlns:d=\"DAV:\">"
+                         "<d:prop xmlns:oc=\"http://owncloud.org/ns\">"
+                         "<oc:message/>"
+                         "</d:prop>"
+                         "</d:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
+    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
     
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     [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 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);
 

+ 12 - 0
iOSClient/Utility/NCUtility.swift

@@ -394,5 +394,17 @@ class NCUtility: NSObject {
         
         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
+    }
 }