diff --git a/README.md b/README.md index a95bbb2e2..4af3274d8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Session integrates directly with [Oxen Service Nodes](https://docs.oxen.io/about ## Want to contribute? Found a bug or have a feature request? -Please search for any [existing issues](https://github.com/loki-project/session-ios/issues) that describe your bugs in order to avoid duplicate submissions. Submissions can be made by making a pull request to our dev branch. If you don't know where to start contributing, try reading the Github issues page for ideas. +Please search for any [existing issues](https://github.com/session-foundation/session-ios/issues) that describe your bugs in order to avoid duplicate submissions. Submissions can be made by making a pull request to our dev branch. If you don't know where to start contributing, try reading the Github issues page for ideas. ## Build instructions @@ -18,7 +18,46 @@ Build instructions can be found in [BUILDING.md](BUILDING.md). ## Translations -Want to help us translate Session into your language? You can do so at https://crowdin.com/project/session-ios! +Want to help us translate Session into your language? You can do so at https://getsession.org/translate ! + +## Verifying signatures + +**Step 1:** + +Add Jason's GPG key. Jason Rhinelander, a member of the [Session Technology Foundation](https://session.foundation/) and is the current signer for all Session iOS releases. His GPG key can be found on his GitHub and other sources. + +```sh +wget https://github.com/jagerman.gpg +gpg --import jagerman.gpg +``` + +**Step 2:** + +Get the signed hashes for this release. `SESSION_VERSION` needs to be updated for the release you want to verify. + +```sh +export SESSION_VERSION=2.9.1 +wget https://github.com/session-foundation/session-ios/releases/download/$SESSION_VERSION/signature.asc +``` + +**Step 3:** + +Verify the signature of the hashes of the files. + +```sh +gpg --verify signature.asc 2>&1 |grep "Good signature from" +``` + +The command above should print "`Good signature from "Jason Rhinelander...`". If it does, the hashes are valid but we still have to make the sure the signed hashes match the downloaded files. + +**Step 4:** + +Make sure the two commands below return the same hash for the file you are checking. If they do, file is valid. + +``` +sha256sum session-$SESSION_VERSION.ipa +grep .ipa signature.asc +``` ## License diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 274beb585..b93471e5b 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -7874,7 +7874,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPILE_LIB_SESSION = ""; - CURRENT_PROJECT_VERSION = 561; + CURRENT_PROJECT_VERSION = 563; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -7913,7 +7913,7 @@ HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/include/**"; IPHONEOS_DEPLOYMENT_TARGET = 15.6; LIB_SESSION_SOURCE_DIR = "${SRCROOT}/../LibSession-Util"; - MARKETING_VERSION = 2.9.1; + MARKETING_VERSION = 2.9.2; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-Werror=protocol"; OTHER_SWIFT_FLAGS = "-D DEBUG -Xfrontend -warn-long-expression-type-checking=100"; @@ -7952,7 +7952,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Distribution"; COMPILE_LIB_SESSION = ""; - CURRENT_PROJECT_VERSION = 561; + CURRENT_PROJECT_VERSION = 563; ENABLE_BITCODE = NO; ENABLE_MODULE_VERIFIER = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -7987,7 +7987,7 @@ HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/include/**"; IPHONEOS_DEPLOYMENT_TARGET = 15.6; LIB_SESSION_SOURCE_DIR = "${SRCROOT}/../LibSession-Util"; - MARKETING_VERSION = 2.9.1; + MARKETING_VERSION = 2.9.2; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = ( "-DNS_BLOCK_ASSERTIONS=1", @@ -8498,7 +8498,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPILE_LIB_SESSION = YES; - CURRENT_PROJECT_VERSION = 561; + CURRENT_PROJECT_VERSION = 563; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -8539,7 +8539,7 @@ ); IPHONEOS_DEPLOYMENT_TARGET = 15.6; LIB_SESSION_SOURCE_DIR = "${SRCROOT}/../LibSession-Util"; - MARKETING_VERSION = 2.9.1; + MARKETING_VERSION = 2.9.2; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "-fobjc-arc-exceptions", @@ -9166,7 +9166,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Distribution"; COMPILE_LIB_SESSION = YES; - CURRENT_PROJECT_VERSION = 561; + CURRENT_PROJECT_VERSION = 563; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; @@ -9202,7 +9202,7 @@ ); IPHONEOS_DEPLOYMENT_TARGET = 15.6; LIB_SESSION_SOURCE_DIR = "${SRCROOT}/../LibSession-Util"; - MARKETING_VERSION = 2.9.1; + MARKETING_VERSION = 2.9.2; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = ( "-DNS_BLOCK_ASSERTIONS=1", diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 726e5bcd6..d9e2daf8a 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -322,9 +322,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD /// /// Additionally we want to ensure that our timeout timer has enough time to run so make sure we have at least `5 seconds` /// of background execution (if we don't then the process could incorrectly run longer than it should) + let remainingTime: TimeInterval = application.backgroundTimeRemaining + guard - application.backgroundTimeRemaining < TimeInterval.greatestFiniteMagnitude && - application.backgroundTimeRemaining > 5 + remainingTime != TimeInterval.nan && + remainingTime < TimeInterval.greatestFiniteMagnitude && + remainingTime > 5 else { return completionHandler(.failed) } Log.appResumedExecution() @@ -342,7 +345,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD /// /// **Note:** We **MUST** capture both `poller` and `cancellable` strongly in the event handler to ensure neither /// go out of scope until we want them to (we essentually want a retain cycle in this case) - let durationRemainingMs: Int = max(1, Int((application.backgroundTimeRemaining - 5) * 1000)) + let durationRemainingMs: Int = max(1, Int((remainingTime - 5) * 1000)) let timer: DispatchSourceTimer = DispatchSource.makeTimerSource(queue: queue) timer.schedule(deadline: .now() + .milliseconds(durationRemainingMs)) timer.setEventHandler { [poller, dependencies] in diff --git a/Session/Meta/Translations/Localizable.xcstrings b/Session/Meta/Translations/Localizable.xcstrings index 7b4ba14d6..2c548ec67 100644 --- a/Session/Meta/Translations/Localizable.xcstrings +++ b/Session/Meta/Translations/Localizable.xcstrings @@ -182477,6 +182477,17 @@ } } }, + "failedToDownload" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Failed to download" + } + } + } + }, "failures" : { "extractionState" : "manual", "localizations" : { @@ -228723,6 +228734,17 @@ } } }, + "images" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "images" + } + } + } + }, "incognitoKeyboard" : { "extractionState" : "manual", "localizations" : { @@ -289261,6 +289283,17 @@ } } }, + "notificationsFastModeDescriptionHuawei" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "You'll be notified of new messages reliably and immediately using Huawei’s notification servers." + } + } + } + }, "notificationsFastModeDescriptionIos" : { "extractionState" : "manual", "localizations" : { @@ -324725,6 +324758,17 @@ } } }, + "permissionChange" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Permission Change" + } + } + } + }, "permissionMusicAudioDenied" : { "extractionState" : "manual", "localizations" : { @@ -326641,6 +326685,17 @@ } } }, + "permissionsCameraAccessRequiredCallsIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Camera access is required to make video calls. Toggle the \"Camera\" permission in Settings to continue." + } + } + } + }, "permissionsCameraDenied" : { "extractionState" : "manual", "localizations" : { @@ -327108,6 +327163,17 @@ } } }, + "permissionsCameraDescriptionIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Allow access to camera for video calls." + } + } + } + }, "permissionsFaceId" : { "extractionState" : "manual", "localizations" : { @@ -329036,6 +329102,17 @@ } } }, + "permissionsLocalNetworkAccessRequiredCallsIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Local Network access is required to facilitate calls. Toggle the \"Local Network\" permission in Settings to continue." + } + } + } + }, "permissionsLocalNetworkAccessRequiredIos" : { "extractionState" : "manual", "localizations" : { @@ -329047,6 +329124,39 @@ } } }, + "permissionsLocalNetworkChangeDescriptionIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Local Network access is currently enabled. To disable it, toggle the “Local Network” permission in Settings." + } + } + } + }, + "permissionsLocalNetworkDescriptionIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Allow access to local network to facilitate voice and video calls." + } + } + } + }, + "permissionsLocalNetworkIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Local Network" + } + } + } + }, "permissionsMicrophone" : { "extractionState" : "manual", "localizations" : { @@ -329999,6 +330109,17 @@ } } }, + "permissionsMicrophoneAccessRequiredCallsIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Microphone access is required to make calls and record audio messages. Toggle the \"Microphone\" permission in Settings to continue." + } + } + } + }, "permissionsMicrophoneAccessRequiredDesktop" : { "extractionState" : "manual", "localizations" : { @@ -331436,6 +331557,17 @@ } } }, + "permissionsMicrophoneDescriptionIos" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Allow access to microphone for voice calls and audio messages." + } + } + } + }, "permissionsMusicAudio" : { "extractionState" : "manual", "localizations" : { @@ -348957,7 +349089,7 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "An error occurred when trying to load your recovery password.

Please export your logs, then upload the file though the {app_name} Help Desk to help resolve this issue." + "value" : "An error occurred when trying to load your recovery password.

Please export your logs, then upload the file through the {app_name} Help Desk to help resolve this issue." } } } @@ -383179,6 +383311,17 @@ } } }, + "tapToRetry" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Tap to retry" + } + } + } + }, "theContinue" : { "extractionState" : "manual", "localizations" : { @@ -389918,484 +390061,10 @@ "updateNewVersionDescription" : { "extractionState" : "manual", "localizations" : { - "af" : { - "stringUnit" : { - "state" : "translated", - "value" : "n Nuwe weergawe van {app_name} is beskikbaar" - } - }, - "ar" : { - "stringUnit" : { - "state" : "translated", - "value" : "إصدار جديد من {app_name} متاح." - } - }, - "az" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} üçün yeni versiyası mövcuddur." - } - }, - "bal" : { - "stringUnit" : { - "state" : "translated", - "value" : "New version {app_name} wājūd dā." - } - }, - "be" : { - "stringUnit" : { - "state" : "translated", - "value" : "Даступна новая версія {app_name}." - } - }, - "bg" : { - "stringUnit" : { - "state" : "translated", - "value" : "Налична е нова версия на {app_name}." - } - }, - "bn" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} এর একটি নতুন সংস্করণ উপলব্ধ।" - } - }, - "ca" : { - "stringUnit" : { - "state" : "translated", - "value" : "Hi ha disponible una nova versió de {app_name}" - } - }, - "cs" : { - "stringUnit" : { - "state" : "translated", - "value" : "Je dostupná nová verze {app_name}." - } - }, - "cy" : { - "stringUnit" : { - "state" : "translated", - "value" : "Mae fersiwn newydd o {app_name} ar gael." - } - }, - "da" : { - "stringUnit" : { - "state" : "translated", - "value" : "En ny version af {app_name} er tilgængelig." - } - }, - "de" : { - "stringUnit" : { - "state" : "translated", - "value" : "Eine neue Version von {app_name} ist verfügbar." - } - }, - "el" : { - "stringUnit" : { - "state" : "translated", - "value" : "Μια νέα έκδοση της εφαρμογής {app_name} είναι διαθέσιμη." - } - }, "en" : { "stringUnit" : { "state" : "translated", - "value" : "A new version of {app_name} is available." - } - }, - "eo" : { - "stringUnit" : { - "state" : "translated", - "value" : "Nova versio de {app_name} disponeblas." - } - }, - "es-419" : { - "stringUnit" : { - "state" : "translated", - "value" : "Hay una nueva versión de {app_name} disponible." - } - }, - "es-ES" : { - "stringUnit" : { - "state" : "translated", - "value" : "Hay una nueva versión de {app_name} disponible." - } - }, - "et" : { - "stringUnit" : { - "state" : "translated", - "value" : "Uus versioon {app_name} on saadaval." - } - }, - "eu" : { - "stringUnit" : { - "state" : "translated", - "value" : "Bertsio berri bat erabilgarri dago {app_name}-erako." - } - }, - "fa" : { - "stringUnit" : { - "state" : "translated", - "value" : "نسخه جدیدی از {app_name} موجود است." - } - }, - "fi" : { - "stringUnit" : { - "state" : "translated", - "value" : "Uusi versio {app_name} on saatavilla." - } - }, - "fil" : { - "stringUnit" : { - "state" : "translated", - "value" : "May bagong bersyon ng {app_name} na magagamit." - } - }, - "fr" : { - "stringUnit" : { - "state" : "translated", - "value" : "Une nouvelle version de {app_name} est disponible." - } - }, - "gl" : { - "stringUnit" : { - "state" : "translated", - "value" : "Hai dispoñible unha nova versión de {app_name}." - } - }, - "ha" : { - "stringUnit" : { - "state" : "translated", - "value" : "Sabuwar sigar {app_name} yana nan." - } - }, - "he" : { - "stringUnit" : { - "state" : "translated", - "value" : "גרסה חדשה של {app_name} זמינה." - } - }, - "hi" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} का एक नया संस्करण उपलब्ध है।" - } - }, - "hr" : { - "stringUnit" : { - "state" : "translated", - "value" : "Dostupna je nova verzija {app_name}." - } - }, - "hu" : { - "stringUnit" : { - "state" : "translated", - "value" : "A(z) {app_name} új verziója elérhető." - } - }, - "hy-AM" : { - "stringUnit" : { - "state" : "translated", - "value" : "Հասանելի է {app_name} նոր տարբերակը:" - } - }, - "id" : { - "stringUnit" : { - "state" : "translated", - "value" : "Versi baru {app_name} telah tersedia." - } - }, - "it" : { - "stringUnit" : { - "state" : "translated", - "value" : "È disponibile una nuova versione di {app_name}." - } - }, - "ja" : { - "stringUnit" : { - "state" : "translated", - "value" : "新バージョンの {app_name} が利用可能です" - } - }, - "ka" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name}-ის ახალი ვერსია ხელმისაწვდომია." - } - }, - "km" : { - "stringUnit" : { - "state" : "translated", - "value" : "កំណែថ្មីរបស់ {app_name} ចេញហើយ។" - } - }, - "kn" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} ನ ಹೊಸ ಆವೃತ್ತಿ ಲಭ್ಯವಿದೆ." - } - }, - "ko" : { - "stringUnit" : { - "state" : "translated", - "value" : "새 버전의 {app_name}이 사용 가능합니다." - } - }, - "ku" : { - "stringUnit" : { - "state" : "translated", - "value" : "وەشانێکی نوێی {app_name} بەردەستە." - } - }, - "ku-TR" : { - "stringUnit" : { - "state" : "translated", - "value" : "Wêşaneke nû ya {app_name} berdeste." - } - }, - "lg" : { - "stringUnit" : { - "state" : "translated", - "value" : "Enkyukakyuka empya ya {app_name} eriwo." - } - }, - "lo" : { - "stringUnit" : { - "state" : "translated", - "value" : "ວິທີໃຫມ່ຂອງ {app_name} ມີໃຫ້." - } - }, - "lt" : { - "stringUnit" : { - "state" : "translated", - "value" : "Yra prieinama nauja {app_name} versija." - } - }, - "lv" : { - "stringUnit" : { - "state" : "translated", - "value" : "Ir pieejama jauna {app_name} versija." - } - }, - "mk" : { - "stringUnit" : { - "state" : "translated", - "value" : "Достапна е нова верзија на {app_name}." - } - }, - "mn" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} шинэ хувилбар гарсан байна." - } - }, - "ms" : { - "stringUnit" : { - "state" : "translated", - "value" : "Versi baru {app_name} tersedia." - } - }, - "my" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} အသစ်ဗားရှင်း ရရှိနေပီး။" - } - }, - "nb" : { - "stringUnit" : { - "state" : "translated", - "value" : "En ny versjon av {app_name} er tilgjengelig." - } - }, - "nb-NO" : { - "stringUnit" : { - "state" : "translated", - "value" : "En ny versjon av {app_name} er tilgjengelig." - } - }, - "ne-NP" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} को नयाँ संस्करण उपलब्ध छ।" - } - }, - "nl" : { - "stringUnit" : { - "state" : "translated", - "value" : "Er is een nieuwe versie van {app_name} beschikbaar." - } - }, - "nn-NO" : { - "stringUnit" : { - "state" : "translated", - "value" : "Ein ny versjon av {app_name} er tilgjengelig." - } - }, - "ny" : { - "stringUnit" : { - "state" : "translated", - "value" : "Mtundu watsopano wa {app_name} ulipezeka." - } - }, - "pa-IN" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} ਦਾ ਨਵਾਂ ਵਰਜ਼ਨ ਉਪਲਬਧ ਹੈ।" - } - }, - "pl" : { - "stringUnit" : { - "state" : "translated", - "value" : "Dostępna jest nowa wersja aplikacji {app_name}." - } - }, - "ps" : { - "stringUnit" : { - "state" : "translated", - "value" : "د {app_name} نوې نسخه شتون لري." - } - }, - "pt-BR" : { - "stringUnit" : { - "state" : "translated", - "value" : "Uma nova versão de {app_name} está disponível." - } - }, - "pt-PT" : { - "stringUnit" : { - "state" : "translated", - "value" : "Uma nova versão de {app_name} está disponível." - } - }, - "ro" : { - "stringUnit" : { - "state" : "translated", - "value" : "Este disponibilă o nouă versiune de {app_name}." - } - }, - "ru" : { - "stringUnit" : { - "state" : "translated", - "value" : "Доступна новая версия {app_name}." - } - }, - "sh" : { - "stringUnit" : { - "state" : "translated", - "value" : "Nova verzija {app_name} je dostupna." - } - }, - "si-LK" : { - "stringUnit" : { - "state" : "translated", - "value" : "නව අනුවාදයක් {app_name} ලාබා ගත හැක." - } - }, - "sk" : { - "stringUnit" : { - "state" : "translated", - "value" : "K dispozícii je nová verzia {app_name}." - } - }, - "sl" : { - "stringUnit" : { - "state" : "translated", - "value" : "Na voljo je nova različica {app_name}." - } - }, - "sq" : { - "stringUnit" : { - "state" : "translated", - "value" : "Është gati një version i ri i {app_name}." - } - }, - "sr" : { - "stringUnit" : { - "state" : "translated", - "value" : "Нова верзија {app_name} је доступна." - } - }, - "sr-Latn" : { - "stringUnit" : { - "state" : "translated", - "value" : "Nova verzija {app_name} je dostupna." - } - }, - "sv-SE" : { - "stringUnit" : { - "state" : "translated", - "value" : "En ny version av {app_name} är tillgänglig." - } - }, - "sw" : { - "stringUnit" : { - "state" : "translated", - "value" : "Toleo jipya la {app_name} linapatikana." - } - }, - "ta" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} இன் புதிய பதிப்பு கிடைக்கிறது." - } - }, - "te" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} యొక్క కొత్త సంస్కరణ అందుబాటులో ఉంది." - } - }, - "th" : { - "stringUnit" : { - "state" : "translated", - "value" : "มีเวอร์ชั่นใหม่ของ {app_name} พร้อมใช้งาน" - } - }, - "tr" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} yeni bir sürümü mevcut." - } - }, - "uk" : { - "stringUnit" : { - "state" : "translated", - "value" : "Доступна нова версія {app_name}." - } - }, - "ur-IN" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} کا ایک نیا ورژن دستیاب ہے۔" - } - }, - "uz" : { - "stringUnit" : { - "state" : "translated", - "value" : "{app_name} ning yangi versiyasi mavjud." - } - }, - "vi" : { - "stringUnit" : { - "state" : "translated", - "value" : "Một phiên bản mới của {app_name} đã có." - } - }, - "xh" : { - "stringUnit" : { - "state" : "translated", - "value" : "Uhlobo olutsha lwe-{app_name} luyafumaneka." - } - }, - "zh-CN" : { - "stringUnit" : { - "state" : "translated", - "value" : "有新版本的{app_name}可用。" - } - }, - "zh-TW" : { - "stringUnit" : { - "state" : "translated", - "value" : "有新版本的 {app_name}。" + "value" : "A new version ({version}) of {app_name} is available." } } } diff --git a/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift b/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift index 8f82aa7dd..e28083e94 100644 --- a/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift +++ b/SessionMessagingKit/LibSession/LibSession+SessionMessagingKit.swift @@ -608,15 +608,8 @@ public extension LibSession { // Only generate the push data if we need to do a push guard config.needsPush else { return } - guard let data: PendingChanges.PushData = config.push(variant: info.variant) else { - throw LibSessionError( - config, - fallbackError: .unableToGeneratePushData, - logMessage: "Failed to generate push data for \(info.variant) config data, size: \(config.countDescription), error" - ) - } - - result.append(data: data) + // Try to generate the push data (will throw if there is an error) + try result.append(data: config.push(variant: info.variant)) } } diff --git a/SessionMessagingKit/LibSession/Types/Config.swift b/SessionMessagingKit/LibSession/Types/Config.swift index 2786adf11..b9ee340d9 100644 --- a/SessionMessagingKit/LibSession/Types/Config.swift +++ b/SessionMessagingKit/LibSession/Types/Config.swift @@ -124,12 +124,22 @@ public extension LibSession { // MARK: - Functions - func push(variant: ConfigDump.Variant) -> PendingChanges.PushData? { + func push(variant: ConfigDump.Variant) throws -> PendingChanges.PushData? { switch self { case .userProfile(let conf), .contacts(let conf), .convoInfoVolatile(let conf), .userGroups(let conf), .groupInfo(let conf), .groupMembers(let conf): - let cPushData: UnsafeMutablePointer = config_push(conf) + /// The `config_push` function implicitly unwraps it's value but can throw internally so call it in a guard + /// statement to prevent the implicit unwrap from causing a crash (ideally it would return a standard optional + /// so the compiler would warn us but it's not that straight forward when dealing with C) + guard let cPushData: UnsafeMutablePointer = config_push(conf) else { + throw LibSessionError( + self, + fallbackError: .unableToGeneratePushData, + logMessage: "Failed to generate push data for \(variant) config data, size: \(countDescription), error" + ) + } + let pushData: Data = Data( bytes: cPushData.pointee.config, count: cPushData.pointee.config_len