Skip to content
Open
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 @@ -798,7 +798,8 @@ public final class ClientSessionComponent {
mlsService: mlsService,
conversationLocalStore: conversationLocalStore,
conversationRepository: conversationRepository,
lockRepository: resetMLSConversationLockRepository
lockRepository: resetMLSConversationLockRepository,
selfDomain: backendMetadata.domain
)

public lazy var mlsTransport: any WireCoreCryptoUniffi.MlsTransport = MLSTransportImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,58 @@ public class InitiateResetMLSConversationUseCase: InitiateResetMLSConversationUs
private let conversationLocalStore: ConversationLocalStoreProtocol
private let conversationRepository: ConversationRepositoryProtocol
private let lockRepository: ResetMLSConversationLockRepositoryProtocol
private let selfDomain: String?

public init(
api: MLSAPI,
mlsService: MLSServiceInterface,
conversationLocalStore: ConversationLocalStoreProtocol,
conversationRepository: ConversationRepositoryProtocol,
lockRepository: ResetMLSConversationLockRepositoryProtocol
lockRepository: ResetMLSConversationLockRepositoryProtocol,
selfDomain: String?
) {
self.api = api
self.mlsService = mlsService
self.conversationLocalStore = conversationLocalStore
self.conversationRepository = conversationRepository
self.lockRepository = lockRepository
self.selfDomain = selfDomain
}

public func invoke(groupID: WireDataModel.MLSGroupID, epoch: UInt64) async {

public func invoke(
groupID: WireDataModel.MLSGroupID,
epoch: UInt64
) async {
var attributes: LogAttributes = [:]

do {
guard let selfDomain else {
WireLogger.mls.error("Can't initiate reset broken MLS conversation failed: self domain unknown")
return
}

guard let conversation = await conversationLocalStore.fetchMLSConversation(groupID: groupID),
let qualifiedID = await conversationLocalStore.qualifiedID(for: conversation)
guard
let conversation = await conversationLocalStore.fetchMLSConversation(groupID: groupID),
let qualifiedID = await conversationLocalStore.qualifiedID(for: conversation)
else {
WireLogger.mls.error("Initiate reset broken MLS conversation failed: no conversation found")
return
}

<<<<<<< HEAD
attributes = [.conversationId: qualifiedID.safeForLoggingDescription]
=======
guard qualifiedID.domain == selfDomain else {
WireLogger.mls.warn("Can't initiate reset broken MLS conversation for other domains")
return
}

attributes = [
.public: true,
.conversationId: qualifiedID.safeForLoggingDescription,
.mlsGroupID: groupID.safeForLoggingDescription
]
>>>>>>> e2853ef371 (fix: don't reset federated conversations - WPB-22499 🍒 (#4048))
Comment on lines +77 to +90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge conflicts


lockRepository.setInitiatedReset(conversationID: qualifiedID)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ final class InitiateResetMLSConversationUseCaseTests: XCTestCase {
mlsService: mockMLSService,
conversationLocalStore: mockConversationLocalStore,
conversationRepository: mockConversationRepository,
lockRepository: mockResetLockRepository
lockRepository: mockResetLockRepository,
selfDomain: conversationID.domain
)
}

Expand Down Expand Up @@ -120,4 +121,25 @@ final class InitiateResetMLSConversationUseCaseTests: XCTestCase {
XCTAssertEqual(mockResetLockRepository.setInitiatedResetConversationID_Invocations.count, 0)
}

func testInvoke_DoNothing_WhenConversationDomainIsNotSelfDomain() async {

// Given - conversation with different domain
let otherDomain = "other.example.com"
let otherDomainConversationID = QualifiedID(uuid: conversationID.uuid, domain: otherDomain)
mockConversationLocalStore.qualifiedIDFor_MockValue = otherDomainConversationID

let groupID = MLSGroupID.random()
// When
await sut.invoke(groupID: groupID, epoch: 99)

// Then
XCTAssertEqual(mockConversationLocalStore.fetchMLSConversationGroupID_Invocations.count, 1)
XCTAssertEqual(mockConversationLocalStore.qualifiedIDFor_Invocations.count, 1)
XCTAssertEqual(mockAPI.resetMLSConversationEpochGroupID_Invocations.count, 0)
XCTAssertEqual(mockMLSService.wipeGroup_Invocations.count, 0)
XCTAssertEqual(mockMLSService.establishPendingGroupGroupID_Invocations.count, 0)
XCTAssertEqual(mockResetLockRepository.setInitiatedResetConversationID_Invocations.count, 0)
XCTAssertEqual(mockConversationRepository.pullConversationIdDomain_Invocations.count, 0)
}

}
2 changes: 1 addition & 1 deletion wire-ios-build-assets
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,8 @@ extension ZMUserSession: SyncAgentDelegate {
conversationRepository: clientSessionComponent.conversationRepository,
lockRepository: ResetMLSConversationLockRepository(
userID: userId
)
),
selfDomain: resolvedBackendMetadata.domain
)
}

Expand Down