Skip to content
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

fix: update group state when fetching conversation during slow sync WPB-11247 🍒 #3033

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type = excluded.type,
team_id = excluded.team_id,
mls_group_id = excluded.mls_group_id,
mls_epoch = excluded.mls_epoch,
mls_group_state = excluded.mls_group_state,
protocol = excluded.protocol,
muted_status = excluded.muted_status,
muted_time = excluded.muted_time,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ class ConversationDAOTest : BaseDatabaseTest() {
assertNull(result)
}

@Test
fun givenExistingConversation_WhenReinserting_ThenGroupStateIsUpdated() = runTest {
conversationDAO.insertConversation(conversationEntity2)
conversationDAO.insertConversation(conversationEntity2.copy(
protocolInfo = mlsProtocolInfo1.copy(
groupState = ConversationEntity.GroupState.PENDING_JOIN
)
))
val result = conversationDAO.getConversationByQualifiedID(conversationEntity2.id)
assertEquals(ConversationEntity.GroupState.PENDING_JOIN, (result?.protocolInfo as ConversationEntity.ProtocolInfo.MLS).groupState)
}

@Test
fun givenExistingConversation_ThenConversationCanBeUpdated() = runTest {
conversationDAO.insertConversation(conversationEntity1)
Expand Down Expand Up @@ -2043,6 +2055,21 @@ class ConversationDAOTest : BaseDatabaseTest() {
isMLSCapable = false
)

val mlsProtocolInfo1 = ConversationEntity.ProtocolInfo.MLS(
"group2",
ConversationEntity.GroupState.ESTABLISHED,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
)
val mlsProtocolInfo2 = ConversationEntity.ProtocolInfo.MLS(
"group3",
ConversationEntity.GroupState.PENDING_JOIN,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
)

val team = TeamEntity(teamId, "teamName", "")

val conversationEntity1 = ConversationEntity(
Expand Down Expand Up @@ -2072,13 +2099,7 @@ class ConversationDAOTest : BaseDatabaseTest() {
"conversation2",
ConversationEntity.Type.ONE_ON_ONE,
null,
ConversationEntity.ProtocolInfo.MLS(
"group2",
ConversationEntity.GroupState.ESTABLISHED,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
),
protocolInfo = mlsProtocolInfo1,
creatorId = "someValue",
lastNotificationDate = null,
lastModifiedDate = "2021-03-30T15:36:00.000Z".toInstant(),
Expand All @@ -2101,13 +2122,7 @@ class ConversationDAOTest : BaseDatabaseTest() {
"conversation3",
ConversationEntity.Type.GROUP,
null,
ConversationEntity.ProtocolInfo.MLS(
"group3",
ConversationEntity.GroupState.PENDING_JOIN,
0UL,
Instant.parse("2021-03-30T15:36:00.000Z"),
cipherSuite = ConversationEntity.CipherSuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
),
protocolInfo = mlsProtocolInfo2,
creatorId = "someValue",
// This conversation was modified after the last time the user was notified about it
lastNotificationDate = "2021-03-30T15:30:00.000Z".toInstant(),
Expand Down
Loading