Skip to content

Commit 222994a

Browse files
Merge pull request #1014 from session-foundation/release/1.21.1
Release 1.21.1
2 parents 1228e1a + db18b80 commit 222994a

File tree

10 files changed

+47
-26
lines changed

10 files changed

+47
-26
lines changed

.drone.jsonnet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/
8383
'apt-get update --allow-releaseinfo-change',
8484
'apt-get install -y ninja-build openjdk-17-jdk',
8585
'update-java-alternatives -s java-1.17.0-openjdk-amd64',
86-
'./gradlew assemblePlayDebug',
86+
'./gradlew assemblePlayDebug assembleWebsiteDebug',
87+
'./gradlew -Phuawei=1 assembleHuaweiDebug',
8788
'./scripts/drone-static-upload.sh'
8889
],
8990
}

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ configurations.configureEach {
1515
exclude module: "commons-logging"
1616
}
1717

18-
def canonicalVersionCode = 396
19-
def canonicalVersionName = "1.21.0"
18+
def canonicalVersionCode = 397
19+
def canonicalVersionName = "1.21.1"
2020

2121
def postFixSize = 10
2222
def abiPostFix = ['armeabi-v7a' : 1,

app/src/huawei/kotlin/org/thoughtcrime/securesms/notifications/HuaweiTokenFetcher.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
99
import kotlinx.coroutines.launch
1010
import kotlinx.coroutines.withContext
1111
import org.session.libsession.messaging.notifications.TokenFetcher
12+
import org.session.libsignal.utilities.Log
1213
import javax.inject.Inject
1314
import javax.inject.Singleton
1415

@@ -25,13 +26,22 @@ class HuaweiTokenFetcher @Inject constructor(
2526
this.token.value = token
2627
}
2728

29+
override suspend fun resetToken() {
30+
withContext(Dispatchers.Default) {
31+
HmsInstanceId.getInstance(context).deleteToken(APP_ID, TOKEN_SCOPE)
32+
}
33+
}
34+
2835
init {
2936
GlobalScope.launch {
30-
val instanceId = HmsInstanceId.getInstance(context)
31-
withContext(Dispatchers.Default) {
32-
instanceId.getToken(APP_ID, TOKEN_SCOPE)
37+
try {
38+
val instanceId = HmsInstanceId.getInstance(context)
39+
withContext(Dispatchers.Default) {
40+
instanceId.getToken(APP_ID, TOKEN_SCOPE)
41+
}
42+
} catch (e: Exception) {
43+
Log.e("HuaweiTokenFetcher", "Failed to fetch token", e)
3344
}
3445
}
35-
3646
}
3747
}

app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import androidx.lifecycle.ProcessLifecycleOwner;
4141
import androidx.work.Configuration;
4242

43-
import com.google.firebase.messaging.FirebaseMessaging;
4443
import com.squareup.phrase.Phrase;
4544

4645
import org.conscrypt.Conscrypt;

app/src/main/java/org/thoughtcrime/securesms/util/ClearDataUtils.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.util
33
import android.annotation.SuppressLint
44
import android.app.Application
55
import android.content.Intent
6-
import com.google.firebase.messaging.FirebaseMessaging
76
import kotlinx.coroutines.Dispatchers
87
import kotlinx.coroutines.delay
98
import kotlinx.coroutines.withContext
@@ -15,11 +14,12 @@ import org.thoughtcrime.securesms.dependencies.ConfigFactory
1514
import org.thoughtcrime.securesms.home.HomeActivity
1615
import javax.inject.Inject
1716
import androidx.core.content.edit
18-
import kotlinx.coroutines.tasks.await
17+
import org.session.libsession.messaging.notifications.TokenFetcher
1918

2019
class ClearDataUtils @Inject constructor(
2120
private val application: Application,
2221
private val configFactory: ConfigFactory,
22+
private val tokenFetcher: TokenFetcher,
2323
) {
2424
// Method to clear the local data - returns true on success otherwise false
2525
@SuppressLint("ApplySharedPref")
@@ -36,9 +36,9 @@ class ClearDataUtils @Inject constructor(
3636

3737
// The token deletion is nice but not critical, so don't let it block the rest of the process
3838
runCatching {
39-
FirebaseMessaging.getInstance().deleteToken().await()
39+
tokenFetcher.resetToken()
4040
}.onFailure { e ->
41-
Log.w("ClearDataUtils", "Failed to delete Firebase token: ${e.message}", e)
41+
Log.w("ClearDataUtils", "Failed to reset push notification token: ${e.message}", e)
4242
}
4343
}
4444
}

app/src/play/kotlin/org/thoughtcrime/securesms/notifications/FirebaseTokenFetcher.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.notifications
22

33
import com.google.firebase.messaging.FirebaseMessaging
44
import kotlinx.coroutines.flow.MutableStateFlow
5+
import kotlinx.coroutines.tasks.await
56
import org.session.libsession.messaging.notifications.TokenFetcher
67
import javax.inject.Inject
78
import javax.inject.Singleton
@@ -19,4 +20,8 @@ class FirebaseTokenFetcher @Inject constructor(): TokenFetcher {
1920
override fun onNewToken(token: String) {
2021
this.token.value = token
2122
}
23+
24+
override suspend fun resetToken() {
25+
FirebaseMessaging.getInstance().deleteToken().await()
26+
}
2227
}

app/src/website/kotlin/org/thoughtcrime/securesms/notifications/NoOpPushModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import dagger.Module
55
import dagger.Provides
66
import dagger.hilt.InstallIn
77
import dagger.hilt.components.SingletonComponent
8-
import javax.inject.Singleton
8+
import org.session.libsession.messaging.notifications.TokenFetcher
99

1010
@Module
1111
@InstallIn(SingletonComponent::class)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package org.thoughtcrime.securesms.notifications
22

3+
import kotlinx.coroutines.flow.MutableStateFlow
4+
import kotlinx.coroutines.flow.StateFlow
5+
import org.session.libsession.messaging.notifications.TokenFetcher
36
import javax.inject.Inject
47
import javax.inject.Singleton
58

69
@Singleton
710
class NoOpTokenFetcher @Inject constructor() : TokenFetcher {
8-
override suspend fun fetch(): String? = null
11+
override val token: StateFlow<String?> = MutableStateFlow(null)
12+
13+
override fun onNewToken(token: String) {}
14+
override suspend fun resetToken() {}
915
}

libsession/src/main/java/org/session/libsession/messaging/notifications/TokenFetcher.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ interface TokenFetcher {
1212
val token: StateFlow<String?>
1313

1414
fun onNewToken(token: String)
15+
suspend fun resetToken()
1516
}

libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/Poller.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,20 @@ class Poller(
107107
Log.d(TAG, "Polling...")
108108

109109
isPolling = true
110+
var pollDelay = RETRY_INTERVAL_MS
111+
try {
112+
// check if the polling pool is empty
113+
if (pollPool.isEmpty()){
114+
// if it is empty, fill it with the snodes from our swarm
115+
pollPool.addAll(SnodeAPI.getSwarm(userPublicKey).await())
116+
}
110117

111-
// check if the polling pool is empty
112-
if(pollPool.isEmpty()){
113-
// if it is empty, fill it with the snodes from our swarm
114-
pollPool.addAll(SnodeAPI.getSwarm(userPublicKey).await())
115-
}
116-
117-
// randomly get a snode from the pool
118-
val currentNode = pollPool.random()
118+
// randomly get a snode from the pool
119+
val currentNode = pollPool.random()
119120

120-
// remove that snode from the pool
121-
pollPool.remove(currentNode)
121+
// remove that snode from the pool
122+
pollPool.remove(currentNode)
122123

123-
var pollDelay = RETRY_INTERVAL_MS
124-
try {
125124
poll(currentNode)
126125
retryScalingFactor = 1f
127126
} catch (e: Exception){

0 commit comments

Comments
 (0)