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(conversation): disable addMember on a one-on-one conversation with deleted account (WPB-10259) 🍒 🍒 #3471

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,6 @@ data class ConversationSheetContent(
fun canAddToFavourite(): Boolean =
(conversationTypeDetail is ConversationTypeDetail.Private && conversationTypeDetail.blockingState != BlockingState.BLOCKED)
|| conversationTypeDetail is ConversationTypeDetail.Group

fun isAbandonedOneOnOneConversation(participantsCount: Int): Boolean = title.isEmpty() && participantsCount == 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ private fun GroupConversationDetailsContent(
GroupConversationDetailsTabItem.PARTICIPANTS -> GroupConversationParticipants(
groupParticipantsState = groupParticipantsState,
onProfilePressed = onProfilePressed,
lazyListState = lazyListStates[pageIndex]
lazyListState = lazyListStates[pageIndex],
isAbandonedOneOnOneConversation = conversationSheetState.conversationSheetContent?.isAbandonedOneOnOneConversation(
groupParticipantsState.data.allCount
) ?: false

)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ fun GroupConversationParticipants(
onProfilePressed: (UIParticipant) -> Unit,
groupParticipantsState: GroupConversationParticipantsState,
modifier: Modifier = Modifier,
lazyListState: LazyListState = rememberLazyListState()
lazyListState: LazyListState = rememberLazyListState(),
isAbandonedOneOnOneConversation: Boolean = false
) {
val context = LocalContext.current
Column(modifier = modifier) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.common.bottomsheet.conversation

import com.wire.android.ui.home.conversations.details.GroupConversationDetailsViewModelTest.Companion.testGroup
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.id.TeamId
import kotlinx.coroutines.test.runTest
import org.amshove.kluent.internal.assertEquals
import org.junit.jupiter.api.Test

class ConversationSheetContentTest {

@Test
fun givenTitleIsEmptyAndTheGroupSizeIsOne_whenCallingIsTheGroupAbandoned_returnsTrue() = runTest {
val details = testGroup.copy(conversation = testGroup.conversation.copy(teamId = TeamId("team_id")))

val givenConversationSheetContent = ConversationSheetContent(
title = "",
conversationId = details.conversation.id,
mutingConversationState = details.conversation.mutedStatus,
conversationTypeDetail = ConversationTypeDetail.Group(details.conversation.id, details.isSelfUserCreator),
selfRole = Conversation.Member.Role.Member,
isTeamConversation = details.conversation.isTeamGroup(),
isArchived = false,
protocol = Conversation.ProtocolInfo.Proteus,
mlsVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
isUnderLegalHold = false
)
val givenParticipantsCount = 1

assertEquals(true, givenConversationSheetContent.isAbandonedOneOnOneConversation(givenParticipantsCount))
}

@Test
fun givenTitleIsEmptyAndTheGroupSizeIsGtOne_whenCallingIsTheGroupAbandoned_returnsFalse() = runTest {
val details = testGroup.copy(conversation = testGroup.conversation.copy(teamId = TeamId("team_id")))

val givenConversationSheetContent = ConversationSheetContent(
title = "",
conversationId = details.conversation.id,
mutingConversationState = details.conversation.mutedStatus,
conversationTypeDetail = ConversationTypeDetail.Group(details.conversation.id, details.isSelfUserCreator),
selfRole = Conversation.Member.Role.Member,
isTeamConversation = details.conversation.isTeamGroup(),
isArchived = false,
protocol = Conversation.ProtocolInfo.Proteus,
mlsVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
isUnderLegalHold = false
)
val givenParticipantsCount = 3

assertEquals(false, givenConversationSheetContent.isAbandonedOneOnOneConversation(givenParticipantsCount))
}

@Test
fun givenTitleIsNotEmptyAndTheGroupSizeIsOne_whenCallingIsTheGroupAbandoned_returnsFalse() = runTest {
val details = testGroup.copy(conversation = testGroup.conversation.copy(teamId = TeamId("team_id")))

val givenConversationSheetContent = ConversationSheetContent(
title = "notEmpty",
conversationId = details.conversation.id,
mutingConversationState = details.conversation.mutedStatus,
conversationTypeDetail = ConversationTypeDetail.Group(details.conversation.id, details.isSelfUserCreator),
selfRole = Conversation.Member.Role.Member,
isTeamConversation = details.conversation.isTeamGroup(),
isArchived = false,
protocol = Conversation.ProtocolInfo.Proteus,
mlsVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
proteusVerificationStatus = Conversation.VerificationStatus.NOT_VERIFIED,
isUnderLegalHold = false
)
val givenParticipantsCount = 3

assertEquals(false, givenConversationSheetContent.isAbandonedOneOnOneConversation(givenParticipantsCount))
}
}
Loading