Skip to content

Commit

Permalink
fix: missing notifications due to LegalHold not Notified (WPB-10351) …
Browse files Browse the repository at this point in the history
β€¦πŸ’ πŸ’ (#2910)

* fix: missing notifications due to LegalHold not Notified (WPB-10351) πŸ’ (#2906)

* Commit with unresolved merge conflicts

* fix: missing notifications due to not lh notified

* fix: missing notifications due to not lh notified

* test: clearer test

---------

Co-authored-by: Yamil Medina <yamilmedina@users.noreply.github.com>

* chore: empty commit bump

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Yamil Medina <yamilmedina@users.noreply.github.com>
github-actions[bot] and yamilmedina authored Jul 26, 2024
1 parent 17b3e1b commit cd67594
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -17,15 +17,15 @@ WITH NumberedMessages AS (
c.type AS conversationType,
c.degraded_conversation_notified AS degradedConversationNotified,
c.legal_hold_status AS legalHoldStatus,
lhs.legal_hold_status_change_notified AS legalHoldStatusChangeNotified,
IFNULL(lhs.legal_hold_status_change_notified, 1) == 1 AS legalHoldStatusChangeNotified,
ROW_NUMBER() OVER (PARTITION BY m.conversation_id ORDER BY m.creation_date DESC) AS row_num
FROM
Message m
JOIN
User u ON m.sender_user_id = u.qualified_id
JOIN
Conversation c ON m.conversation_id = c.qualified_id
JOIN
LEFT JOIN
ConversationLegalHoldStatusChangeNotified AS lhs ON m.conversation_id == lhs.conversation_id AND (m.creation_date > IFNULL(c.last_notified_date, 0))
LEFT JOIN
MessageAssetContent ac ON m.id = ac.message_id AND m.conversation_id = ac.conversation_id
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ import com.wire.kalium.persistence.dao.QualifiedIDEntity
import com.wire.kalium.persistence.dao.UserAvailabilityStatusEntity
import com.wire.kalium.persistence.dao.conversation.ConversationEntity
import com.wire.kalium.persistence.utils.stubs.newRegularMessageEntity
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Clock
import kotlin.test.Test
@@ -31,7 +30,6 @@ import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlin.time.Duration.Companion.hours

@OptIn(ExperimentalCoroutinesApi::class)
class MessageNotificationsTest : BaseMessageTest() {

@Test
@@ -105,6 +103,23 @@ class MessageNotificationsTest : BaseMessageTest() {
}
}

@Test
fun givenConversation_whenNoLegalHoldNotified_thenNotificationIsPresent() = runTest {
val message = OTHER_MESSAGE
val messageOtherConvo2 = OTHER_MESSAGE_CONVO2
// going to super to not insert legal hold values
insertInitialData()
// just inserting legal hold for one conversation
conversationDAO.updateLegalHoldStatusChangeNotified(TEST_CONVERSATION_1.id, false)
messageDAO.insertOrIgnoreMessages(listOf(message, messageOtherConvo2))

messageDAO.getNotificationMessage().let { notifications ->
assertEquals(2, notifications.size)
assertEquals(false, notifications.first { it.conversationId == TEST_CONVERSATION_1.id }.legalHoldStatusChangeNotified)
assertEquals(true, notifications.first { it.conversationId == TEST_CONVERSATION_2.id }.legalHoldStatusChangeNotified)
}
}

@Test
fun givenNewMessageInserted_whenConvInAllMutedState_thenNeedsToBeNotifyIsFalse() = runTest {
val conversationMutedStatus = ConversationEntity.MutedStatus.ALL_MUTED
@@ -356,9 +371,6 @@ class MessageNotificationsTest : BaseMessageTest() {

override suspend fun insertInitialData() {
super.insertInitialData()
// Always insert original messages
conversationDAO.updateLegalHoldStatusChangeNotified(TEST_CONVERSATION_1.id, true)
conversationDAO.updateLegalHoldStatusChangeNotified(TEST_CONVERSATION_2.id, true)
}

private companion object {
@@ -378,6 +390,13 @@ class MessageNotificationsTest : BaseMessageTest() {
content = MessageEntityContent.Text(OTHER_MESSAGE_CONTENT)
)

val OTHER_MESSAGE_CONVO2 = newRegularMessageEntity(
id = "OTHER_MESSAGE",
conversationId = TEST_CONVERSATION_2.id,
senderUserId = ORIGINAL_MESSAGE_SENDER.id,
content = MessageEntityContent.Text(OTHER_MESSAGE_CONTENT)
)

val OTHER_QUOTING_OTHERS = newRegularMessageEntity(
id = "OTHER_QUOTING_OTHERS",
conversationId = TEST_CONVERSATION_1.id,

0 comments on commit cd67594

Please sign in to comment.