From 238cab78b11caf22ef8cb0e2cd9a28db6009cb9f Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 7 Nov 2018 03:48:00 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20try=20to=20set=20notification?= =?UTF-8?q?=20level=20if=20we=20can=E2=80=99t=20do=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DatabaseStorageModule.java | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferencestorage/DatabaseStorageModule.java b/app/src/main/java/com/nextcloud/talk/utils/preferencestorage/DatabaseStorageModule.java index 834af04a2..88ed85611 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferencestorage/DatabaseStorageModule.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferencestorage/DatabaseStorageModule.java @@ -70,45 +70,47 @@ public class DatabaseStorageModule implements StorageModule { if (!key.equals("message_notification_level")) { arbitraryStorageUtils.storeStorageSetting(accountIdentifier, key, value, conversationToken); } else { - int intValue; - switch (value) { - case "never": - intValue = 3; - break; - case "mention": - intValue = 2; - break; - case "always": - intValue = 1; - break; - default: - intValue = 0; + if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) { + int intValue; + switch (value) { + case "never": + intValue = 3; + break; + case "mention": + intValue = 2; + break; + case "always": + intValue = 1; + break; + default: + intValue = 0; + } + + ncApi.setNotificationLevel(ApiUtils.getCredentials(conversationUser.getUsername(), conversationUser.getToken()), + ApiUtils.getUrlForSettingNotificationlevel(conversationUser.getBaseUrl(), conversationToken), + intValue) + .subscribeOn(Schedulers.newThread()) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(GenericOverall genericOverall) { + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + } + }); } - - ncApi.setNotificationLevel(ApiUtils.getCredentials(conversationUser.getUsername(), conversationUser.getToken()), - ApiUtils.getUrlForSettingNotificationlevel(conversationUser.getBaseUrl(), conversationToken), - intValue) - .subscribeOn(Schedulers.newThread()) - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { - - } - - @Override - public void onNext(GenericOverall genericOverall) { - - } - - @Override - public void onError(Throwable e) { - - } - - @Override - public void onComplete() { - } - }); } }