diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index c4552ca719..a18a9ae92d 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -487,7 +487,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc String userPublicKey = TextSecurePreferences.getLocalNumber(this); if (userPublicKey == null) return; if (lokiPoller != null) { - lokiPoller.updateUserHexEncodedPublicKey(userPublicKey); + LokiAPI.shared.setUserHexEncodedPublicKey(userPublicKey); + lokiPoller.setUserHexEncodedPublicKey(userPublicKey); return; } LokiAPIDatabase apiDB = DatabaseFactory.getLokiAPIDatabase(this); @@ -507,8 +508,9 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc if (lokiPoller != null) { lokiPoller.startIfNeeded(); } } - public void stopPollingIfNeeded() { - if (lokiPoller != null) { lokiPoller.stopIfNeeded(); } + public void stopPolling() { + if (lokiPoller == null) { return; } + lokiPoller.stopIfNeeded(); } private void resubmitProfilePictureIfNeeded() { diff --git a/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt index 0e0a4d96ab..b3109cc1d4 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt @@ -146,6 +146,6 @@ class LandingActivity : BaseActionBarActivity(), LinkDeviceSlaveModeDialogDelega TextSecurePreferences.setHasSeenWelcomeScreen(this, false) TextSecurePreferences.setPromptedPushRegistration(this, false) val application = ApplicationContext.getInstance(this) - application.stopPollingIfNeeded() + application.stopPolling() } } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt index 6df6fa85f6..f18ddab0cf 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt @@ -17,6 +17,7 @@ import org.whispersystems.libsignal.SignalProtocolAddress import org.whispersystems.signalservice.api.messages.SignalServiceContent import org.whispersystems.signalservice.api.messages.SignalServiceGroup import org.whispersystems.signalservice.api.push.SignalServiceAddress +import org.whispersystems.signalservice.loki.api.LokiAPI import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol import java.util.* @@ -108,6 +109,7 @@ object ClosedGroupsProtocol { val deviceAsAddress = SignalProtocolAddress(device, SignalServiceAddress.DEFAULT_DEVICE_ID) val hasSession = TextSecureSessionStore(context).containsSession(deviceAsAddress) if (hasSession) { continue } + if (DatabaseFactory.getLokiAPIDatabase(context).getSessionRequestTimestamp(device) != null) { return } DatabaseFactory.getLokiAPIDatabase(context).setSessionRequestTimestamp(device, Date().time) val sessionRequest = EphemeralMessage.createSessionRequest(device) ApplicationContext.getInstance(context).jobManager.add(PushEphemeralMessageSendJob(sessionRequest))