mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 20:19:42 +01:00
extract methods and add log commands in AccountRemovalWorker
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
cb11c36400
commit
c2032b6554
@ -96,7 +96,6 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
||||||
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
||||||
|
|
||||||
String finalCredentials = credentials;
|
|
||||||
ncApi.unregisterDeviceForNotificationsWithNextcloud(credentials, ApiUtils.getUrlNextcloudPush(userEntity
|
ncApi.unregisterDeviceForNotificationsWithNextcloud(credentials, ApiUtils.getUrlNextcloudPush(userEntity
|
||||||
.getBaseUrl()))
|
.getBaseUrl()))
|
||||||
.blockingSubscribe(new Observer<GenericOverall>() {
|
.blockingSubscribe(new Observer<GenericOverall>() {
|
||||||
@ -114,90 +113,13 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
queryMap.put("userPublicKey", finalPushConfigurationState.getUserPublicKey());
|
queryMap.put("userPublicKey", finalPushConfigurationState.getUserPublicKey());
|
||||||
queryMap.put("deviceIdentifierSignature",
|
queryMap.put("deviceIdentifierSignature",
|
||||||
finalPushConfigurationState.getDeviceIdentifierSignature());
|
finalPushConfigurationState.getDeviceIdentifierSignature());
|
||||||
|
unregisterDeviceForNotificationWithProxy(queryMap, userEntity);
|
||||||
ncApi.unregisterDeviceForNotificationsWithProxy
|
|
||||||
(ApiUtils.getUrlPushProxy(), queryMap)
|
|
||||||
.subscribe(new Observer<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(Void aVoid) {
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
String groupName = String.format(getApplicationContext().getResources()
|
|
||||||
.getString(R.string
|
|
||||||
.nc_notification_channel), userEntity.getUserId(), userEntity.getBaseUrl());
|
|
||||||
CRC32 crc32 = new CRC32();
|
|
||||||
crc32.update(groupName.getBytes());
|
|
||||||
NotificationManager notificationManager =
|
|
||||||
(NotificationManager) getApplicationContext().getSystemService
|
|
||||||
(Context.NOTIFICATION_SERVICE);
|
|
||||||
|
|
||||||
if (notificationManager != null) {
|
|
||||||
notificationManager.deleteNotificationChannelGroup(Long
|
|
||||||
.toString(crc32.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WebSocketConnectionHelper.deleteExternalSignalingInstanceForUserEntity(userEntity.getId());
|
|
||||||
|
|
||||||
arbitraryStorageUtils.deleteAllEntriesForAccountIdentifier(userEntity.getId()).subscribe(new Observer() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(Object o) {
|
|
||||||
userUtils.deleteUser(userEntity.getId()).subscribe(new CompletableObserver() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
|
Log.e(TAG, "error while trying to unregister Device For Notifications", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -206,46 +128,101 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
userUtils.deleteUser(userEntity.getId())
|
deleteUser(userEntity);
|
||||||
.subscribe(new CompletableObserver() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.d(TAG, "Something went wrong while removing job at parsing PushConfigurationState");
|
Log.d(TAG, "Something went wrong while removing job at parsing PushConfigurationState");
|
||||||
userUtils.deleteUser(userEntity.getId())
|
deleteUser(userEntity);
|
||||||
.subscribe(new CompletableObserver() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unregisterDeviceForNotificationWithProxy(HashMap<String, String> queryMap, UserEntity userEntity) {
|
||||||
|
ncApi.unregisterDeviceForNotificationsWithProxy
|
||||||
|
(ApiUtils.getUrlPushProxy(), queryMap)
|
||||||
|
.subscribe(new Observer<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(Void aVoid) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
String groupName = String.format(getApplicationContext().getResources()
|
||||||
|
.getString(R.string
|
||||||
|
.nc_notification_channel), userEntity.getUserId(), userEntity.getBaseUrl());
|
||||||
|
CRC32 crc32 = new CRC32();
|
||||||
|
crc32.update(groupName.getBytes());
|
||||||
|
NotificationManager notificationManager =
|
||||||
|
(NotificationManager) getApplicationContext().getSystemService
|
||||||
|
(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
if (notificationManager != null) {
|
||||||
|
notificationManager.deleteNotificationChannelGroup(Long
|
||||||
|
.toString(crc32.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WebSocketConnectionHelper.deleteExternalSignalingInstanceForUserEntity(userEntity.getId());
|
||||||
|
deleteAllEntriesForAccountIdentifier(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e(TAG, "error while trying to unregister Device For Notification With Proxy", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteAllEntriesForAccountIdentifier(UserEntity userEntity) {
|
||||||
|
arbitraryStorageUtils.deleteAllEntriesForAccountIdentifier(userEntity.getId()).subscribe(new Observer() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(Object o) {
|
||||||
|
deleteUser(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e(TAG, "error while trying to delete All Entries For Account Identifier", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteUser(UserEntity userEntity) {
|
||||||
|
String username = userEntity.getUsername();
|
||||||
|
userUtils.deleteUser(userEntity.getId())
|
||||||
|
.subscribe(new CompletableObserver() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.d(TAG, "deleted user: " + username);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e(TAG, "error while trying to delete user", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user