Skip to content

Release 1.21.1 #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/
'apt-get update --allow-releaseinfo-change',
'apt-get install -y ninja-build openjdk-17-jdk',
'update-java-alternatives -s java-1.17.0-openjdk-amd64',
'./gradlew assemblePlayDebug',
'./gradlew assemblePlayDebug assembleWebsiteDebug',
'./gradlew -Phuawei=1 assembleHuaweiDebug',
'./scripts/drone-static-upload.sh'
],
}
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ configurations.configureEach {
exclude module: "commons-logging"
}

def canonicalVersionCode = 396
def canonicalVersionName = "1.21.0"
def canonicalVersionCode = 397
def canonicalVersionName = "1.21.1"

def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.session.libsession.messaging.notifications.TokenFetcher
import org.session.libsignal.utilities.Log
import javax.inject.Inject
import javax.inject.Singleton

Expand All @@ -25,13 +26,22 @@ class HuaweiTokenFetcher @Inject constructor(
this.token.value = token
}

override suspend fun resetToken() {
withContext(Dispatchers.Default) {
HmsInstanceId.getInstance(context).deleteToken(APP_ID, TOKEN_SCOPE)
}
}

init {
GlobalScope.launch {
val instanceId = HmsInstanceId.getInstance(context)
withContext(Dispatchers.Default) {
instanceId.getToken(APP_ID, TOKEN_SCOPE)
try {
val instanceId = HmsInstanceId.getInstance(context)
withContext(Dispatchers.Default) {
instanceId.getToken(APP_ID, TOKEN_SCOPE)
}
} catch (e: Exception) {
Log.e("HuaweiTokenFetcher", "Failed to fetch token", e)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import androidx.lifecycle.ProcessLifecycleOwner;
import androidx.work.Configuration;

import com.google.firebase.messaging.FirebaseMessaging;
import com.squareup.phrase.Phrase;

import org.conscrypt.Conscrypt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.util
import android.annotation.SuppressLint
import android.app.Application
import android.content.Intent
import com.google.firebase.messaging.FirebaseMessaging
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
Expand All @@ -15,11 +14,12 @@ import org.thoughtcrime.securesms.dependencies.ConfigFactory
import org.thoughtcrime.securesms.home.HomeActivity
import javax.inject.Inject
import androidx.core.content.edit
import kotlinx.coroutines.tasks.await
import org.session.libsession.messaging.notifications.TokenFetcher

class ClearDataUtils @Inject constructor(
private val application: Application,
private val configFactory: ConfigFactory,
private val tokenFetcher: TokenFetcher,
) {
// Method to clear the local data - returns true on success otherwise false
@SuppressLint("ApplySharedPref")
Expand All @@ -36,9 +36,9 @@ class ClearDataUtils @Inject constructor(

// The token deletion is nice but not critical, so don't let it block the rest of the process
runCatching {
FirebaseMessaging.getInstance().deleteToken().await()
tokenFetcher.resetToken()
}.onFailure { e ->
Log.w("ClearDataUtils", "Failed to delete Firebase token: ${e.message}", e)
Log.w("ClearDataUtils", "Failed to reset push notification token: ${e.message}", e)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.notifications

import com.google.firebase.messaging.FirebaseMessaging
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.tasks.await
import org.session.libsession.messaging.notifications.TokenFetcher
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -19,4 +20,8 @@ class FirebaseTokenFetcher @Inject constructor(): TokenFetcher {
override fun onNewToken(token: String) {
this.token.value = token
}

override suspend fun resetToken() {
FirebaseMessaging.getInstance().deleteToken().await()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import org.session.libsession.messaging.notifications.TokenFetcher

@Module
@InstallIn(SingletonComponent::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.thoughtcrime.securesms.notifications

import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import org.session.libsession.messaging.notifications.TokenFetcher
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class NoOpTokenFetcher @Inject constructor() : TokenFetcher {
override suspend fun fetch(): String? = null
override val token: StateFlow<String?> = MutableStateFlow(null)

override fun onNewToken(token: String) {}
override suspend fun resetToken() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ interface TokenFetcher {
val token: StateFlow<String?>

fun onNewToken(token: String)
suspend fun resetToken()
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,20 @@ class Poller(
Log.d(TAG, "Polling...")

isPolling = true
var pollDelay = RETRY_INTERVAL_MS
try {
// check if the polling pool is empty
if (pollPool.isEmpty()){
// if it is empty, fill it with the snodes from our swarm
pollPool.addAll(SnodeAPI.getSwarm(userPublicKey).await())
}

// check if the polling pool is empty
if(pollPool.isEmpty()){
// if it is empty, fill it with the snodes from our swarm
pollPool.addAll(SnodeAPI.getSwarm(userPublicKey).await())
}

// randomly get a snode from the pool
val currentNode = pollPool.random()
// randomly get a snode from the pool
val currentNode = pollPool.random()

// remove that snode from the pool
pollPool.remove(currentNode)
// remove that snode from the pool
pollPool.remove(currentNode)

var pollDelay = RETRY_INTERVAL_MS
try {
poll(currentNode)
retryScalingFactor = 1f
} catch (e: Exception){
Expand Down