Skip to content
Snippets Groups Projects
Commit e4aeda3b authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Merge branch 'FE-1053_change_retry_behavior' into internal_build

parents ab7b6412 2925a7df
No related branches found
No related tags found
No related merge requests found
......@@ -35,8 +35,8 @@ android {
defaultConfig {
applicationId = "io.xxlabs.messenger"
versionCode = 630
versionName = "2.93"
versionCode = 637
versionName = "2.95"
minSdk = 26
targetSdk = 31
testInstrumentationRunner = "io.xxlabs.messenger.CustomTestRunner"
......
......@@ -52,6 +52,9 @@ interface ClientWrapperBase {
): Long
fun confirmAuthenticatedChannel(marshalledContact: ByteArray): Long
fun deleteRequest(marshalledContact: ByteArray)
fun waitForRoundCompletion(
roundId: Long,
timeoutMillis: Long,
......
......@@ -139,6 +139,10 @@ class ClientWrapperBindings(
return client.confirmAuthenticatedChannel(marshalledContact)
}
override fun deleteRequest(marshalledContact: ByteArray) {
client.deleteRequest(marshalledContact)
}
override fun waitForRoundCompletion(
roundId: Long,
timeoutMillis: Long,
......
......@@ -88,6 +88,8 @@ class ClientWrapperMock(val contact: ContactData) : ClientWrapperBase {
return Random.nextLong()
}
override fun deleteRequest(marshalledContact: ByteArray) {}
override fun waitForRoundCompletion(
roundId: Long,
timeoutMillis: Long,
......
......@@ -291,18 +291,18 @@ class MessagingService : FirebaseMessagingService(), HasAndroidInjector {
private fun NotificationForMeReport.notificationText(): String =
when {
isGroupRequest() -> getString(R.string.notification_group_request_text)
isRequest() -> getString(R.string.notification_request_text)
isRequest() || isReset() -> getString(R.string.notification_request_text)
isConfirm() -> getString(R.string.notification_confirm_text)
isE2E() -> getString(R.string.notification_e2e_text)
isGroup() -> getString(R.string.notification_group_text)
isEndFT() -> getString(R.string.notification_endft_text)
isReset() -> getString(R.string.notification_reset_text)
// isReset() -> getString(R.string.notification_reset_text)
else -> "New activity" // Other types should not be displayed in the first place.
}
private fun NotificationForMeReport.channelId(): String =
when {
isRequest() || isGroupRequest() -> getString(R.string.request_notification_channel_id)
isRequest() || isGroupRequest() || isReset() -> getString(R.string.request_notification_channel_id)
isConfirm() -> getString(R.string.confirm_notification_channel_id)
isE2E() || isEndFT() -> getString(R.string.e2e_notification_channel_id)
isGroup() -> getString(R.string.group_notification_channel_id)
......@@ -311,7 +311,7 @@ class MessagingService : FirebaseMessagingService(), HasAndroidInjector {
private fun NotificationForMeReport.channelName(): String =
when {
isRequest() || isGroupRequest() -> getString(R.string.notification_request_channel_label)
isRequest() || isGroupRequest() || isReset() -> getString(R.string.notification_request_channel_label)
isConfirm() -> getString(R.string.notification_confirm_channel_label)
isE2E() || isEndFT() -> getString(R.string.notification_e2e_channel_label)
isGroup() -> getString(R.string.notification_group_channel_label)
......
package io.xxlabs.messenger.requests.bindings
import com.dropbox.core.android.AuthActivity.result
import io.xxlabs.messenger.bindings.wrapper.contact.ContactWrapperBase
import io.xxlabs.messenger.data.room.model.Contact
import io.xxlabs.messenger.repository.base.BaseRepository
......@@ -64,15 +65,34 @@ class BindingsRequestMediator @Inject constructor(
override suspend fun verifyContactRequest(request: ContactRequest): VerificationResult =
requestVerifier.verifyRequest(request)
override suspend fun deleteContactRequest(request: ContactRequest): Boolean {
return deleteContactRequest(request.model)
}
private fun deleteContactRequest(contact: Contact): Boolean {
var result = false
try {
ClientRepository.clientWrapper.client.deleteRequest(contact.userId)
result = true
} catch (e: Exception) {
Timber.d(
"Exception occurred when deleting request for ${contact.displayName}: ${e.message}."
)
}
return result
}
override fun resetSession(contact: Contact): Boolean {
var result = false
try {
if (deleteContactRequest(contact)) {
val roundId = ClientRepository.clientWrapper.client.resetSession(
contact.marshaled,
repo.getMashalledUser(),
""
)
result = roundId > 0
}
} catch (e: Exception) {
Timber.d(
"Exception occurred when resetting ${contact.displayName}: ${e.message}."
......
......@@ -7,5 +7,6 @@ interface ContactRequestsService {
suspend fun acceptContactRequest(request: ContactRequest): Boolean
suspend fun sendContactRequest(request: ContactRequest): Boolean
suspend fun verifyContactRequest(request: ContactRequest): VerificationResult
suspend fun deleteContactRequest(request: ContactRequest): Boolean
fun resetSession(contact: Contact): Boolean
}
\ No newline at end of file
......@@ -70,6 +70,7 @@ class ContactRequestsRepository @Inject constructor(
override fun delete(request: ContactRequest) {
scope.launch {
requestsService.deleteContactRequest(request)
localDataSource.getRequest(request.requestId)?.apply {
localDataSource.deleteRequest(this)
}
......@@ -94,8 +95,8 @@ class ContactRequestsRepository @Inject constructor(
scope.launch {
when (request.requestStatus) {
VERIFICATION_FAIL -> verify(request)
RESET_FAIL, RESET_SENT -> resetSession(request)
SEND_FAIL, SENT -> resendRequest(request)
SEND_FAIL, SENT, RESET_FAIL, RESET_SENT -> resetSession(request)
// SEND_FAIL, SENT -> resendRequest(request)
CONFIRM_FAIL -> accept(request)
SENDING -> sendRequest(request)
else -> Timber.d("Unknown request status: ${request.requestStatus.value}")
......@@ -149,7 +150,7 @@ class ContactRequestsRepository @Inject constructor(
}
private fun resetSession(request: ContactRequest) {
if (requestsService.resetSession(request.model)) update(request, RESET_SENT)
if (requestsService.resetSession(request.model)) update(request, RESENT)
else update(request, RESET_FAIL)
}
......
rootProject.name = "xx Messenger Legacy"
include(":app", ":xx_bindings", ":linkpreview", ":proto")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment