heavyrain2012 5 yıl önce
ebeveyn
işleme
b326eea2be

+ 14 - 13
wfchat/WildFireChat/AppService/AppService.m

@@ -200,13 +200,13 @@ static AppService *sharedSingleton = nil;
         if (uploadedFiles.count) {
             [uploadedFiles removeLastObject];
         }
-        
-        if (![uploadedFiles isKindOfClass:[NSMutableArray class]]) {
-            uploadedFiles = [[NSMutableArray alloc] init];
+        for (NSString *file in [logFiles copy]) {
+            NSString *name = [file componentsSeparatedByString:@"/"].lastObject;
+            if ([uploadedFiles containsObject:name]) {
+                [logFiles removeObject:file];
+            }
         }
         
-        [logFiles removeObjectsInArray:uploadedFiles];
-        
         
         __block NSString *errorMsg = nil;
         
@@ -222,18 +222,23 @@ static AppService *sharedSingleton = nil;
 
             [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                 NSData *logData = [NSData dataWithContentsOfFile:logFile];
+                if (!logData.length) {
+                    logData = [@"empty" dataUsingEncoding:NSUTF8StringEncoding];
+                }
                 
                 NSString *fileName = [[NSURL URLWithString:logFile] lastPathComponent];
-                
                 [formData appendPartWithFileData:logData name:@"file" fileName:fileName mimeType:@"application/octet-stream"];
-                
             } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
-                
                 if ([responseObject isKindOfClass:[NSDictionary class]]) {
                     NSDictionary *dict = (NSDictionary *)responseObject;
                     if([dict[@"code"] intValue] == 0) {
                         NSLog(@"上传成功");
                         success = YES;
+                        NSString *name = [logFile componentsSeparatedByString:@"/"].lastObject;
+                        [uploadedFiles removeObject:name];
+                        [uploadedFiles addObject:name];
+                        [[NSUserDefaults standardUserDefaults] setObject:uploadedFiles forKey:@"mars_uploaded_files"];
+                        [[NSUserDefaults standardUserDefaults] synchronize];
                     }
                 }
                 if (!success) {
@@ -248,11 +253,7 @@ static AppService *sharedSingleton = nil;
             
             dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
             
-            if (success) {
-                [uploadedFiles addObject:logFile];
-                [[NSUserDefaults standardUserDefaults] setObject:uploadedFiles forKey:@"mars_uploaded_files"];
-                [[NSUserDefaults standardUserDefaults] synchronize];
-            } else {
+            if (!success) {
                 errorBlock(errorMsg);
                 return;
             }

+ 1 - 3
wfchat/WildFireChat/WFCConfig.m

@@ -12,12 +12,10 @@
 //例如:example.com或www.example.com或im.example.com或imtest.example.com是支持的;xx.example.com或xx.yy.example.com是不支持的。如果是专业版必须用域名。
 NSString *IM_SERVER_HOST = @"wildfirechat.cn";
 
-//客户端强制使用80端口,不能使用其它端口。需要确保服务器运行在在国内时处于备案状态,确保运营IM服务处在监管之下。
-//int IM_SERVER_PORT = 80;
 
 //正式商用时,建议用https,确保token安全
 NSString *APP_SERVER_ADDRESS = @"http://wildfirechat.cn:8888";
-//NSString *APP_SERVER_ADDRESS = @"https://wildfirechat.cn/app";
+//NSString *APP_SERVER_ADDRESS = @"https://app.wildfirechat.cn";
 
 NSString *ICE_ADDRESS = @"turn:turn.wildfirechat.cn:3478";
 NSString *ICE_USERNAME = @"wfchat";