File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
commonMain/kotlin/com/wire/kalium/persistence/dao/conversation
commonTest/kotlin/com/wire/kalium/persistence/dao Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ interface ConversationDAO {
106106 suspend fun getConversationsWithoutMetadata (): List <QualifiedIDEntity >
107107 suspend fun clearContent (conversationId : QualifiedIDEntity )
108108 suspend fun updateMlsVerificationStatus (verificationStatus : ConversationEntity .VerificationStatus , conversationId : QualifiedIDEntity )
109- suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity
109+ suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity ?
110110 suspend fun observeUnreadArchivedConversationsCount (): Flow <Long >
111111 suspend fun observeDegradedConversationNotified (conversationId : QualifiedIDEntity ): Flow <Boolean >
112112 suspend fun updateDegradedConversationNotifiedFlag (conversationId : QualifiedIDEntity , updateFlag : Boolean )
Original file line number Diff line number Diff line change @@ -247,10 +247,10 @@ internal class ConversationDAOImpl internal constructor(
247247 .map { it?.let { conversationMapper.toModel(it) } }
248248 }
249249
250- override suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity {
250+ override suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity ? {
251251 return conversationQueries.selectByGroupId(groupID)
252- .executeAsOne ()
253- .let { it.let { conversationMapper.toModel(it) } }
252+ .executeAsOneOrNull ()
253+ ? .let { it.let { conversationMapper.toModel(it) } }
254254 }
255255
256256 override suspend fun getConversationIdByGroupID (groupID : String ) = withContext(coroutineContext) {
Original file line number Diff line number Diff line change @@ -1826,6 +1826,22 @@ class ConversationDAOTest : BaseDatabaseTest() {
18261826 }
18271827 }
18281828
1829+ @Test
1830+ fun givenInsertedConversations_whenGettingConversationByInexistingGroupId_thenReturnNull () = runTest {
1831+ // given
1832+ val expected = null
1833+ conversationDAO.insertConversation(conversationEntity4)
1834+
1835+ // when
1836+ val result = conversationDAO.getConversationByGroupID(" call_subconversation_groupid" )
1837+
1838+ // then
1839+ assertEquals(
1840+ expected,
1841+ result
1842+ )
1843+ }
1844+
18291845 private fun ConversationEntity.toViewEntity (userEntity : UserEntity ? = null): ConversationViewEntity {
18301846 val protocol: ConversationEntity .Protocol
18311847 val mlsGroupId: String?
You can’t perform that action at this time.
0 commit comments