Skip to content

Commit

Permalink
Merge branch 'release/cycle-3.115' into fix/ci-snapshots-WPB-14950
Browse files Browse the repository at this point in the history
  • Loading branch information
netbe authored Dec 16, 2024
2 parents 1f0a8a8 + 53c0402 commit f69fb3f
Show file tree
Hide file tree
Showing 56 changed files with 69 additions and 651 deletions.
2 changes: 1 addition & 1 deletion WireLogging/Sources/WireLogging/SystemLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public struct SystemLogger: LoggerProtocol {
}

public func warn(_ message: any LogConvertible, attributes: LogAttributes...) {
log(message, attributes: attributes, osLogType: .fault)
log(message, attributes: attributes, osLogType: .default)
}

public func error(_ message: any LogConvertible, attributes: LogAttributes...) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,4 @@
}
},
"version" : "1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol {
}

private func configureProteusClient(coreCrypto: SafeCoreCrypto) async throws {
try await coreCrypto.perform { try await $0.proteusInit() }
// here we don't need to lock the context or restoreFromDisk()
// it fixes `Mls(WireCoreCrypto.MlsError.Other("Proteus client hasn\'t been initialized"))`
// Empty transaction was committed, this could be an indication of a programming error - [core_crypto_context:
// {}]
try await coreCrypto.unsafePerform { try await $0.proteusInit() }
}

private func configureMLSClient(coreCrypto: SafeCoreCrypto) async throws {
Expand Down
6 changes: 3 additions & 3 deletions wire-ios-data-model/Source/Core Crypto/SafeCoreCrypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import WireLogging

public protocol SafeCoreCryptoProtocol {
func perform<T>(_ block: (CoreCryptoProtocol) async throws -> T) async rethrows -> T
func unsafePerform<T>(_ block: (CoreCryptoProtocol) throws -> T) rethrows -> T
func unsafePerform<T>(_ block: (CoreCryptoProtocol) async throws -> T) async rethrows -> T
func tearDown() throws
}

Expand Down Expand Up @@ -71,8 +71,8 @@ public class SafeCoreCrypto: SafeCoreCryptoProtocol {
return try await block(coreCrypto)
}

public func unsafePerform<T>(_ block: (CoreCryptoProtocol) throws -> T) rethrows -> T {
try block(coreCrypto)
public func unsafePerform<T>(_ block: (CoreCryptoProtocol) async throws -> T) async rethrows -> T {
try await block(coreCrypto)
}

private func restoreFromDisk() async {
Expand Down
53 changes: 35 additions & 18 deletions wire-ios-data-model/Source/MLS/OneOnOne/OneOnOneMigrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,26 @@ public struct OneOnOneMigrator: OneOnOneMigratorInterface {
userID: QualifiedID,
in context: NSManagedObjectContext
) async throws -> MLSGroupID {
// Fetch MLS 1:1 conversation and store it locally.
let (mlsGroupID, removalKeys) = try await syncMLSConversationFromBackend(
userID: userID,
in: context
)

if try await mlsService.conversationExists(groupID: mlsGroupID) {
return mlsGroupID
}

guard let epoch = await fetchMLSConversationEpoch(mlsGroupID: mlsGroupID, in: context) else {
throw MigrateMLSOneOnOneConversationError.missingConversationEpoch
}

if epoch == 0 {
try await establishMLSGroupIfNeeded(
// Create or join the MLS conversation if needed.
if try await !mlsService.conversationExists(groupID: mlsGroupID) {
try await createOrJoinMLSConversationIfNeeded(
userID: userID,
mlsGroupID: mlsGroupID,
removalKeys: removalKeys,
in: context
)
} else {
try await mlsService.joinGroup(with: mlsGroupID)
in: context)
}

try await switchLocalConversationToMLS(
// Perform the migration of messages and link the MLS conversation if needed.
// It's safe to attempt this step each time to enhance the resilience of the app.
// This ensures that in cases where an MLS conversation exists but Proteus hasn't yet switched and the messages haven't been migrated,
// it will attempt the migration again.
try await migrateMessagesAndLinkMLSConversationIfNeeded(
userID: userID,
mlsGroupID: mlsGroupID,
in: context
Expand Down Expand Up @@ -137,7 +132,7 @@ public struct OneOnOneMigrator: OneOnOneMigratorInterface {
}
}

private func switchLocalConversationToMLS(
private func migrateMessagesAndLinkMLSConversationIfNeeded(
userID: QualifiedID,
mlsGroupID: MLSGroupID,
in context: NSManagedObjectContext
Expand All @@ -155,10 +150,10 @@ public struct OneOnOneMigrator: OneOnOneMigratorInterface {
}

// move local messages from proteus conversation if it exists
if let proteusConversation = otherUser.oneOnOneConversation {
if let existingConversation = otherUser.oneOnOneConversation, existingConversation.messageProtocol == .proteus {
// Since ZMMessages only have a single conversation connected,
// forming this union also removes the relationship to the proteus conversation.
mlsConversation.mutableMessages.union(proteusConversation.allMessages)
mlsConversation.mutableMessages.union(existingConversation.allMessages)

// update just to be sure
mlsConversation.needsToBeUpdatedFromBackend = true
Expand All @@ -168,4 +163,26 @@ public struct OneOnOneMigrator: OneOnOneMigratorInterface {
otherUser.oneOnOneConversation = mlsConversation
}
}

private func createOrJoinMLSConversationIfNeeded(
userID: QualifiedID,
mlsGroupID: MLSGroupID,
removalKeys: BackendMLSPublicKeys?,
in context: NSManagedObjectContext
) async throws {
guard let epoch = await fetchMLSConversationEpoch(mlsGroupID: mlsGroupID, in: context) else {
throw MigrateMLSOneOnOneConversationError.missingConversationEpoch
}

if epoch == 0 {
try await establishMLSGroupIfNeeded(
userID: userID,
mlsGroupID: mlsGroupID,
removalKeys: removalKeys,
in: context
)
} else {
try await mlsService.joinGroup(with: mlsGroupID)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class OneOnOneResolver: OneOnOneResolverInterface {
try await self.resolveOneOnOneConversation(with: userID, in: context)
} catch {
// skip conversation migration for this user
WireLogger.conversation.error("resolve 1-1 conversation with userID \(userID) failed!")
WireLogger.conversation.error("resolve 1-1 conversation with userID \(userID) failed: \(error)")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions wire-ios-data-model/Support/Sources/MockSafeCoreCrypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class MockSafeCoreCrypto: SafeCoreCryptoProtocol {
}

var unsafePerformCount = 0
public func unsafePerform<T>(_ block: (CoreCryptoProtocol) throws -> T) rethrows -> T {
public func unsafePerform<T>(_ block: (CoreCryptoProtocol) async throws -> T) async rethrows -> T {
unsafePerformCount += 1
return try block(coreCrypto)
return try await block(coreCrypto)
}

var performAsyncCount = 0
Expand Down
21 changes: 21 additions & 0 deletions wire-ios-request-strategy/Sources/APIs/NetworkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,24 @@ public enum NetworkError: Error, Equatable {
}
}
}

// MARK: - LocalizedError

extension NetworkError: LocalizedError {
public var errorDescription: String? {
switch self {
case .errorEncodingRequest:
"Failed to encode the request."
case let .errorDecodingResponse(response):
"Failed to decode the response: \(response)."
case let .errorDecodingURLResponse(urlResponse):
"Failed to decode the URL response: \(urlResponse)."
case .endpointNotAvailable:
"The requested endpoint is not available."
case let .missingClients(status, response):
"Missing clients with status: \(status). Response: \(response)."
case let .invalidRequestError(failure, response):
"Invalid request error: \(failure). Response: \(response)."
}
}
}
13 changes: 0 additions & 13 deletions wire-ios/Wire-iOS/Resources/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"peoplepicker.no_matching_results.action.learn_more" = "معرفة المزيد";
"peoplepicker.no_matching_results.action.manage_services" = "إدارة الخدمات";

"peoplepicker.no_matching_results_after_address_book_upload_title" = "لا توجد نتائج.";
"peoplepicker.no_matching_results.message.users" = "Find people in Wire by name or @username";
"peoplepicker.no_matching_results.message.usersAndFederation" = "Find people in Wire by name or @username\n\nFind people on another domain by @username@domainname";
"peoplepicker.no_matching_results.message.users_all_added" = "الجميع حاضرون.";
Expand All @@ -98,7 +97,6 @@
"peoplepicker.send_invitation.dialog.message" = "يمكن استخدامها لمدة أسبوعين. حال انتهاء صلاحيتها أرسل واحدة جديدة.";
"peoplepicker.send_invitation.dialog.ok" = "موافق";

"peoplepicker.invite_more_people" = "ادعُ أشخاصًا أكثر";
"peoplepicker.invite_team_members" = "ادعُ أشخاصًا إلى الانضمام إلى الفريق";
"peoplepicker.quick-action.open-conversation" = "افتح";
"peoplepicker.quick-action.admin-services" = "إدارة الخدمات";
Expand Down Expand Up @@ -1590,17 +1588,6 @@

"registration.country_select.title" = "البلد";

"registration.share_contacts.hero.title" = "إيجاد أُناس على Wire";
"registration.share_contacts.hero.paragraph" = "اسمح لـWire بالوصول لجهات الإتصال الخاصة بك حتى تتمكن من التواصل مع الآخرين. نحن نحفظ سرية معلوماتك ولا نتشاركها من أحد آخر.";
"registration.share_contacts.find_friends_button.title" = "مشاركة جهات الاتصال";
"registration.share_contacts.skip_button.title" = "ليس الآن";

"registration.address_book_access_denied.hero.title" = "لا يملك Wire صلاحية الوصول لجهات اتصالك.";
"registration.address_book_access_denied.hero.paragraph1" = "يساعدك Wire في العثور على أصدقائك عند مشاركة جهات اتصالك.";
"registration.address_book_access_denied.hero.paragraph2" = "لتمكين الوصول اذهب للإعدادات وقم بتفعيله.";
"registration.address_book_access_denied.settings_button.title" = "الإعدادات";
"registration.address_book_access_denied.maybe_later_button.title" = "ربما في وقت لاحق";

"registration.push_access_denied.hero.title" = "لا تُفَوّت أي مُكالمة أو رسالة.";
"registration.push_access_denied.hero.paragraph1" = "فعّل الإشعارات من الإعدادات.";
"registration.push_access_denied.settings_button.title" = "اذهب للإعدادات";
Expand Down
13 changes: 0 additions & 13 deletions wire-ios/Wire-iOS/Resources/be.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"peoplepicker.no_matching_results.action.learn_more" = "Learn more";
"peoplepicker.no_matching_results.action.manage_services" = "Manage Services";

"peoplepicker.no_matching_results_after_address_book_upload_title" = "No results.";
"peoplepicker.no_matching_results.message.users" = "Find people in Wire by name or @username";
"peoplepicker.no_matching_results.message.usersAndFederation" = "Find people in Wire by name or @username\n\nFind people on another domain by @username@domainname";
"peoplepicker.no_matching_results.message.users_all_added" = "Everyone’s here.";
Expand All @@ -98,7 +97,6 @@
"peoplepicker.send_invitation.dialog.message" = "It can be used for 2 weeks. Send a new one if it expires.";
"peoplepicker.send_invitation.dialog.ok" = "OK";

"peoplepicker.invite_more_people" = "Invite more people";
"peoplepicker.invite_team_members" = "Invite people to join the team";
"peoplepicker.quick-action.open-conversation" = "Open";
"peoplepicker.quick-action.admin-services" = "Manage Services";
Expand Down Expand Up @@ -1590,17 +1588,6 @@

"registration.country_select.title" = "Country";

"registration.share_contacts.hero.title" = "Find people on Wire";
"registration.share_contacts.hero.paragraph" = "Share your contacts so we can connect you with others. We anonymize all information and do not share it with anyone else.";
"registration.share_contacts.find_friends_button.title" = "Share contacts";
"registration.share_contacts.skip_button.title" = "Not now";

"registration.address_book_access_denied.hero.title" = "Wire does not have access to your contacts.";
"registration.address_book_access_denied.hero.paragraph1" = "Wire helps find your friends if you share your contacts.";
"registration.address_book_access_denied.hero.paragraph2" = "To enable access tap Settings and turn on Contacts.";
"registration.address_book_access_denied.settings_button.title" = "Settings";
"registration.address_book_access_denied.maybe_later_button.title" = "Maybe later";

"registration.push_access_denied.hero.title" = "Never miss a call or a message.";
"registration.push_access_denied.hero.paragraph1" = "Enable Notifications in Settings.";
"registration.push_access_denied.settings_button.title" = "Go to Settings";
Expand Down
13 changes: 0 additions & 13 deletions wire-ios/Wire-iOS/Resources/bg.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"peoplepicker.no_matching_results.action.learn_more" = "Learn more";
"peoplepicker.no_matching_results.action.manage_services" = "Manage Services";

"peoplepicker.no_matching_results_after_address_book_upload_title" = "No results.";
"peoplepicker.no_matching_results.message.users" = "Find people in Wire by name or @username";
"peoplepicker.no_matching_results.message.usersAndFederation" = "Find people in Wire by name or @username\n\nFind people on another domain by @username@domainname";
"peoplepicker.no_matching_results.message.users_all_added" = "Everyone’s here.";
Expand All @@ -98,7 +97,6 @@
"peoplepicker.send_invitation.dialog.message" = "It can be used for 2 weeks. Send a new one if it expires.";
"peoplepicker.send_invitation.dialog.ok" = "OK";

"peoplepicker.invite_more_people" = "Invite more people";
"peoplepicker.invite_team_members" = "Invite people to join the team";
"peoplepicker.quick-action.open-conversation" = "Open";
"peoplepicker.quick-action.admin-services" = "Manage Services";
Expand Down Expand Up @@ -1590,17 +1588,6 @@

"registration.country_select.title" = "Country";

"registration.share_contacts.hero.title" = "Find people on Wire";
"registration.share_contacts.hero.paragraph" = "Share your contacts so we can connect you with others. We anonymize all information and do not share it with anyone else.";
"registration.share_contacts.find_friends_button.title" = "Share contacts";
"registration.share_contacts.skip_button.title" = "Not now";

"registration.address_book_access_denied.hero.title" = "Wire does not have access to your contacts.";
"registration.address_book_access_denied.hero.paragraph1" = "Wire helps find your friends if you share your contacts.";
"registration.address_book_access_denied.hero.paragraph2" = "To enable access tap Settings and turn on Contacts.";
"registration.address_book_access_denied.settings_button.title" = "Настройки";
"registration.address_book_access_denied.maybe_later_button.title" = "Maybe later";

"registration.push_access_denied.hero.title" = "Never miss a call or a message.";
"registration.push_access_denied.hero.paragraph1" = "Enable Notifications in Settings.";
"registration.push_access_denied.settings_button.title" = "Go to Settings";
Expand Down
13 changes: 0 additions & 13 deletions wire-ios/Wire-iOS/Resources/bn.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"peoplepicker.no_matching_results.action.learn_more" = "Learn more";
"peoplepicker.no_matching_results.action.manage_services" = "Manage Services";

"peoplepicker.no_matching_results_after_address_book_upload_title" = "No results.";
"peoplepicker.no_matching_results.message.users" = "Find people in Wire by name or @username";
"peoplepicker.no_matching_results.message.usersAndFederation" = "Find people in Wire by name or @username\n\nFind people on another domain by @username@domainname";
"peoplepicker.no_matching_results.message.users_all_added" = "Everyone’s here.";
Expand All @@ -98,7 +97,6 @@
"peoplepicker.send_invitation.dialog.message" = "It can be used for 2 weeks. Send a new one if it expires.";
"peoplepicker.send_invitation.dialog.ok" = "ওকে";

"peoplepicker.invite_more_people" = "Invite more people";
"peoplepicker.invite_team_members" = "Invite people to join the team";
"peoplepicker.quick-action.open-conversation" = "খুলুন";
"peoplepicker.quick-action.admin-services" = "Manage Services";
Expand Down Expand Up @@ -1590,17 +1588,6 @@

"registration.country_select.title" = "দেশ";

"registration.share_contacts.hero.title" = "Find people on Wire";
"registration.share_contacts.hero.paragraph" = "Share your contacts so we can connect you with others. We anonymize all information and do not share it with anyone else.";
"registration.share_contacts.find_friends_button.title" = "Share contacts";
"registration.share_contacts.skip_button.title" = "Not now";

"registration.address_book_access_denied.hero.title" = "Wire does not have access to your contacts.";
"registration.address_book_access_denied.hero.paragraph1" = "Wire helps find your friends if you share your contacts.";
"registration.address_book_access_denied.hero.paragraph2" = "To enable access tap Settings and turn on Contacts.";
"registration.address_book_access_denied.settings_button.title" = "সেটিং সমূহ ";
"registration.address_book_access_denied.maybe_later_button.title" = "Maybe later";

"registration.push_access_denied.hero.title" = "Never miss a call or a message.";
"registration.push_access_denied.hero.paragraph1" = "Enable Notifications in Settings.";
"registration.push_access_denied.settings_button.title" = "Go to Settings";
Expand Down
13 changes: 0 additions & 13 deletions wire-ios/Wire-iOS/Resources/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"peoplepicker.no_matching_results.action.learn_more" = "Saber-ne més";
"peoplepicker.no_matching_results.action.manage_services" = "Gestionar els serveis";

"peoplepicker.no_matching_results_after_address_book_upload_title" = "Sense resultats.";
"peoplepicker.no_matching_results.message.users" = "Find people in Wire by name or @username";
"peoplepicker.no_matching_results.message.usersAndFederation" = "Find people in Wire by name or @username\n\nFind people on another domain by @username@domainname";
"peoplepicker.no_matching_results.message.users_all_added" = "Everyone’s here.";
Expand All @@ -98,7 +97,6 @@
"peoplepicker.send_invitation.dialog.message" = "It can be used for 2 weeks. Send a new one if it expires.";
"peoplepicker.send_invitation.dialog.ok" = "D'ACORD";

"peoplepicker.invite_more_people" = "Invite more people";
"peoplepicker.invite_team_members" = "Convida gent a afegir-se a l'equip";
"peoplepicker.quick-action.open-conversation" = "Obre";
"peoplepicker.quick-action.admin-services" = "Gestionar els serveis";
Expand Down Expand Up @@ -1590,17 +1588,6 @@

"registration.country_select.title" = "País";

"registration.share_contacts.hero.title" = "Find people on Wire";
"registration.share_contacts.hero.paragraph" = "Share your contacts so we can connect you with others. We anonymize all information and do not share it with anyone else.";
"registration.share_contacts.find_friends_button.title" = "Comparteix contactes";
"registration.share_contacts.skip_button.title" = "Ara no";

"registration.address_book_access_denied.hero.title" = "Wire does not have access to your contacts.";
"registration.address_book_access_denied.hero.paragraph1" = "Wire helps find your friends if you share your contacts.";
"registration.address_book_access_denied.hero.paragraph2" = "To enable access tap Settings and turn on Contacts.";
"registration.address_book_access_denied.settings_button.title" = "Configuració";
"registration.address_book_access_denied.maybe_later_button.title" = "Maybe later";

"registration.push_access_denied.hero.title" = "Never miss a call or a message.";
"registration.push_access_denied.hero.paragraph1" = "Enable Notifications in Settings.";
"registration.push_access_denied.settings_button.title" = "Go to Settings";
Expand Down
Loading

0 comments on commit f69fb3f

Please sign in to comment.