mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-13 12:07:57 +01:00
Fix call log clustering ignoring the four hour timeout.
Fixes #14712 Resolves #14926 Co-authored-by: Greyson Parrelli <greyson@signal.org>
This commit is contained in:
committed by
Cody Henthorne
co-authored by
Greyson Parrelli
parent
601af08923
commit
4b795a8aa6
@@ -40,6 +40,7 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil
|
||||
import java.util.concurrent.Executor
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
@@ -137,7 +138,7 @@ class CallEventCache(
|
||||
}
|
||||
|
||||
private fun isWithinTimeout(parent: CacheRecord, child: CacheRecord): Boolean {
|
||||
return (child.timestamp - parent.timestamp) <= 4.hours.inWholeMilliseconds
|
||||
return abs(parent.timestamp - child.timestamp) <= 4.hours.inWholeMilliseconds
|
||||
}
|
||||
|
||||
private fun canUserBeginCall(peer: Recipient, decryptedGroup: ByteArray?): CallLogRow.CanStartCall {
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.service.webrtc.CallLinkPeekInfo
|
||||
import org.thoughtcrime.securesms.service.webrtc.SignalCallManager
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
|
||||
class CallEventCacheTest {
|
||||
|
||||
@@ -154,6 +155,42 @@ class CallEventCacheTest {
|
||||
assertThat(result).size().isEqualTo(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given two entries in descending timestamp order outside of time threshold, when I clusterCallEvents, then I expect two entries`() {
|
||||
val testData = listOf(
|
||||
createCacheRecord(
|
||||
callId = 1,
|
||||
timestamp = 1.days.inWholeMilliseconds
|
||||
),
|
||||
createCacheRecord(
|
||||
callId = 2,
|
||||
timestamp = 0
|
||||
)
|
||||
)
|
||||
|
||||
val filterState = CallEventCache.FilterState()
|
||||
val result = CallEventCache.clusterCallEvents(testData, filterState)
|
||||
assertThat(result).size().isEqualTo(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given two entries in descending timestamp order within time threshold, when I clusterCallEvents, then I expect one entry`() {
|
||||
val testData = listOf(
|
||||
createCacheRecord(
|
||||
callId = 1,
|
||||
timestamp = 1.hours.inWholeMilliseconds
|
||||
),
|
||||
createCacheRecord(
|
||||
callId = 2,
|
||||
timestamp = 0
|
||||
)
|
||||
)
|
||||
|
||||
val filterState = CallEventCache.FilterState()
|
||||
val result = CallEventCache.clusterCallEvents(testData, filterState)
|
||||
assertThat(result).size().isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given two entries with a mismatch between them, when I clusterCallEvents, then I expect three entries`() {
|
||||
val testData = listOf(
|
||||
|
||||
Reference in New Issue
Block a user