From 9b832e128565c996e79f5076dc1be754f1d9ea97 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 18 Feb 2024 17:38:32 +0100 Subject: [PATCH] null check PushTargetMessenger --- .../conversations/services/UnifiedPushBroker.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java b/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java index 2562e13a6..bfa1785f1 100644 --- a/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java +++ b/src/main/java/eu/siacs/conversations/services/UnifiedPushBroker.java @@ -12,6 +12,7 @@ import android.preference.PreferenceManager; import android.util.Log; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.common.base.Optional; import com.google.common.base.Strings; @@ -85,24 +86,24 @@ public class UnifiedPushBroker { service.sendPresencePacket(account, presence); } - public Optional renewUnifiedPushEndpoints() { - return renewUnifiedPushEndpoints(null); + public void renewUnifiedPushEndpoints() { + renewUnifiedPushEndpoints(null); } - public Optional renewUnifiedPushEndpoints(final PushTargetMessenger pushTargetMessenger) { + public Optional renewUnifiedPushEndpoints(@Nullable final PushTargetMessenger pushTargetMessenger) { final Optional transportOptional = getTransport(); if (transportOptional.isPresent()) { final Transport transport = transportOptional.get(); if (transport.account.isEnabled()) { renewUnifiedEndpoint(transportOptional.get(), pushTargetMessenger); } else { - if (pushTargetMessenger.messenger != null) { + if (pushTargetMessenger != null && pushTargetMessenger.messenger != null) { sendRegistrationDelayed(pushTargetMessenger.messenger,"account is disabled"); } Log.d(Config.LOGTAG, "skipping UnifiedPush endpoint renewal. Account is disabled"); } } else { - if (pushTargetMessenger.messenger != null) { + if (pushTargetMessenger != null && pushTargetMessenger.messenger != null) { sendRegistrationDelayed(pushTargetMessenger.messenger,"no transport selected"); } Log.d(Config.LOGTAG, "skipping UnifiedPush endpoint renewal. No transport selected");