|
@@ -2337,23 +2337,27 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
-- (void)emptyTrash:(void (^)(NSString *message, NSInteger errorCode))completion
|
|
|
+- (void)emptyTrashWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
|
|
|
{
|
|
|
+ tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
|
|
|
+ if (tableAccount == nil) {
|
|
|
+ completion(account, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
|
|
|
+ }
|
|
|
+
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
- [communication setCredentialsWithUser:_activeUser andUserID:_activeUserID andPassword:_activePassword];
|
|
|
+ [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:tableAccount.password];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- NSString *path = [NSString stringWithFormat:@"%@%@/trashbin/%@/trash", _activeUrl, k_dav, _activeUserID];
|
|
|
+ NSString *path = [NSString stringWithFormat:@"%@%@/trashbin/%@/trash", _activeUrl, k_dav, tableAccount.userID];
|
|
|
|
|
|
[communication emptyTrash:path onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
|
|
- completion(nil, 0);
|
|
|
+ completion(account, 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;
|
|
@@ -2365,9 +2369,9 @@
|
|
|
message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
|
|
|
|
|
|
// Activity
|
|
|
- [[NCManageDatabase sharedInstance] addActivityClient:_activeUrl fileID:@"" action:k_activityDebugActionUnsubscribingServerPush selector:@"" note:[error.userInfo valueForKey:@"NSLocalizedDescription"] type:k_activityTypeFailure verbose:k_activityVerboseHigh activeUrl:_activeUrl];
|
|
|
+ [[NCManageDatabase sharedInstance] addActivityClient:_activeUrl fileID:@"" action:k_activityDebugActionUnsubscribingServerPush selector:@"" note:[error.userInfo valueForKey:@"NSLocalizedDescription"] type:k_activityTypeFailure verbose:k_activityVerboseHigh activeUrl:@""];
|
|
|
|
|
|
- completion(message, errorCode);
|
|
|
+ completion(account, message, errorCode);
|
|
|
}];
|
|
|
}
|
|
|
|