From 77100231d2c3b2bf26d7e005db634aa3adec9550 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 11 Aug 2023 17:37:35 +0930 Subject: [PATCH] Fix logs --- app/src/main/AndroidManifest.xml | 10 -------- .../securesms/notifications/PushReceiver.kt | 23 ++++++------------- .../securesms/notifications/PushRegistry.kt | 11 ++++----- .../notifications/PushRegistryV1.kt | 12 +++------- 4 files changed, 14 insertions(+), 42 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ed51a7ea8d..cc63ab6a87 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -78,16 +78,6 @@ android:theme="@style/Theme.Session.DayNight" tools:replace="android:allowBackup"> - - - - - - = 2) (expectedList[1] as? BencodeString)?.value else null - // null content is valid only if we got a "data_too_long" flag - if (content == null) - check(metadata.data_too_long) { "missing message data, but no too-long flag" } - else - check(metadata.data_len == content.size) { "wrong message data size" } - - Log.d( - TAG, - "Received push for ${metadata.account}/${metadata.namespace}, msg ${metadata.msg_hash}, ${metadata.data_len}B" - ) - - return content + return (expectedList.getOrNull(1) as? BencodeString)?.value.also { + // null content is valid only if we got a "data_too_long" flag + it?.let { check(metadata.data_len == it.size) { "wrong message data size" } } + ?: check(metadata.data_too_long) { "missing message data, but no too-long flag" } + } } fun getOrCreateNotificationKey(): Key { diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt index dc50ad8bdd..718b2b29ca 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt @@ -40,14 +40,14 @@ class PushRegistry @Inject constructor( } pushRegistrationJob = MainScope().launch { - register(tokenFetcher.fetch()) fail { - Log.e(TAG, "register failed", it) + register(tokenFetcher.fetch()) fail { e -> + Log.e(TAG, "register failed", e) } } } fun register(token: String?): Promise<*, Exception> { - Log.d(TAG, "refresh($token) called") + Log.d(TAG, "refresh() called") if (token?.isNotEmpty() != true) return emptyPromise() @@ -72,10 +72,7 @@ class PushRegistry @Inject constructor( userEd25519Key: KeyPair, namespaces: List = listOf(Namespace.DEFAULT) ): Promise<*, Exception> { - Log.d( - TAG, - "register() called with: token = $token, publicKey = $publicKey, userEd25519Key = $userEd25519Key, namespaces = $namespaces" - ) + Log.d(TAG, "register() called") val v1 = PushRegistryV1.register( device = device, diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/notifications/PushRegistryV1.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/notifications/PushRegistryV1.kt index d7d84b5c61..ac5fce6d50 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/notifications/PushRegistryV1.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/notifications/PushRegistryV1.kt @@ -34,23 +34,17 @@ object PushRegistryV1 { legacyGroupPublicKeys: Collection = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys() ): Promise<*, Exception> = when { isUsingFCM -> retryIfNeeded(maxRetryCount) { - android.util.Log.d( - TAG, - "register() called with: device = $device, isUsingFCM = $isUsingFCM, token = $token, publicKey = $publicKey, legacyGroupPublicKeys = $legacyGroupPublicKeys" - ) + Log.d(TAG, "register() called") doRegister(token, publicKey, device, legacyGroupPublicKeys) } fail { exception -> - Log.d(TAG, "Couldn't register for FCM due to error: $exception... $device $token $publicKey $legacyGroupPublicKeys") + Log.d(TAG, "Couldn't register for FCM due to error", exception) } else -> emptyPromise() } private fun doRegister(token: String?, publicKey: String?, device: Device, legacyGroupPublicKeys: Collection): Promise<*, Exception> { - android.util.Log.d( - TAG, - "doRegister() called with: token = $token, publicKey = $publicKey, device = $device, legacyGroupPublicKeys = $legacyGroupPublicKeys" - ) + Log.d(TAG, "doRegister() called") token ?: return emptyPromise() publicKey ?: return emptyPromise()