Skip to content

Commit

Permalink
fix: Change return type of getConversationByGroupID to nullable for e…
Browse files Browse the repository at this point in the history
…poch changes (#2593)

* Commit with unresolved merge conflicts outside of

* empty trigger commit

* chore: fix merge conflicts

---------

Co-authored-by: Alexandre Ferris <[email protected]>
  • Loading branch information
github-actions[bot] and alexandreferris authored Mar 6, 2024
1 parent 72d393f commit 1cfa01f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ interface ConversationDAO {
suspend fun getConversationsWithoutMetadata(): List<QualifiedIDEntity>
suspend fun clearContent(conversationId: QualifiedIDEntity)
suspend fun updateMlsVerificationStatus(verificationStatus: ConversationEntity.VerificationStatus, conversationId: QualifiedIDEntity)
suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity
suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity?
suspend fun observeUnreadArchivedConversationsCount(): Flow<Long>
suspend fun observeDegradedConversationNotified(conversationId: QualifiedIDEntity): Flow<Boolean>
suspend fun updateDegradedConversationNotifiedFlag(conversationId: QualifiedIDEntity, updateFlag: Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ internal class ConversationDAOImpl internal constructor(
.map { it?.let { conversationMapper.toModel(it) } }
}

override suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity {
override suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity? {
return conversationQueries.selectByGroupId(groupID)
.executeAsOne()
.let { it.let { conversationMapper.toModel(it) } }
.executeAsOneOrNull()
?.let { it.let { conversationMapper.toModel(it) } }
}

override suspend fun getConversationIdByGroupID(groupID: String) = withContext(coroutineContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,22 @@ class ConversationDAOTest : BaseDatabaseTest() {
}
}

@Test
fun givenInsertedConversations_whenGettingConversationByInexistingGroupId_thenReturnNull() = runTest {
// given
val expected = null
conversationDAO.insertConversation(conversationEntity4)

// when
val result = conversationDAO.getConversationByGroupID("call_subconversation_groupid")

// then
assertEquals(
expected,
result
)
}

private fun ConversationEntity.toViewEntity(userEntity: UserEntity? = null): ConversationViewEntity {
val protocol: ConversationEntity.Protocol
val mlsGroupId: String?
Expand Down

0 comments on commit 1cfa01f

Please sign in to comment.