diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt index 9925caf7c..9c05a7231 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt @@ -988,7 +988,7 @@ class SettingsController : NewBaseController(R.layout.controller_settings) { } override fun onNext(genericOverall: GenericOverall) { - val statusCode = genericOverall.meta?.statusCode + val statusCode = genericOverall.ocs?.meta?.statusCode if (statusCode == HTTP_CODE) { dialog.dismiss() Toast.makeText( diff --git a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java index 3eb0ea2a3..65e1ad01b 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java @@ -35,6 +35,7 @@ import com.nextcloud.talk.R; import com.nextcloud.talk.api.NcApi; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.models.database.UserEntity; +import com.nextcloud.talk.models.json.generic.GenericMeta; import com.nextcloud.talk.models.json.generic.GenericOverall; import com.nextcloud.talk.models.json.push.PushConfigurationState; import com.nextcloud.talk.utils.ApiUtils; @@ -110,14 +111,16 @@ public class AccountRemovalWorker extends Worker { @Override public void onNext(@NotNull GenericOverall genericOverall) { - if (Objects.requireNonNull(genericOverall.getMeta()).getStatusCode() == 200 || - genericOverall.getMeta().getStatusCode() == 202) { + GenericMeta meta = Objects.requireNonNull(genericOverall.getOcs()).getMeta(); + int statusCode = Objects.requireNonNull(meta).getStatusCode(); + + if (statusCode == 200 || statusCode == 202) { HashMap queryMap = new HashMap<>(); queryMap.put("deviceIdentifier", finalPushConfigurationState.getDeviceIdentifier()); queryMap.put("userPublicKey", finalPushConfigurationState.getUserPublicKey()); queryMap.put("deviceIdentifierSignature", - finalPushConfigurationState.getDeviceIdentifierSignature()); + finalPushConfigurationState.getDeviceIdentifierSignature()); unregisterDeviceForNotificationWithProxy(queryMap, userEntity); } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.kt new file mode 100644 index 000000000..faac6262e --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.kt @@ -0,0 +1,37 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.nextcloud.talk.models.json.generic + +import android.os.Parcelable +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import kotlinx.android.parcel.Parcelize + +@Parcelize +@JsonObject +data class GenericOCS( + @JsonField(name = ["meta"]) + var meta: GenericMeta? = null +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null) +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt index a257638ca..e5bd828b3 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt @@ -29,8 +29,8 @@ import kotlinx.android.parcel.Parcelize @Parcelize @JsonObject data class GenericOverall( - @JsonField(name = ["meta"]) - var meta: GenericMeta? = null + @JsonField(name = ["ocs"]) + var ocs: GenericOCS? = null ) : Parcelable { // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' constructor() : this(null) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 368891b1f..85841457f 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -321,7 +321,7 @@ class MessageActionsDialog( } override fun onNext(@NonNull genericOverall: GenericOverall) { - val statusCode = genericOverall.meta?.statusCode + val statusCode = genericOverall.ocs?.meta?.statusCode if (statusCode == HTTP_CREATED) { chatController.updateAdapterAfterSendReaction(message, emoji) }