From 8ce6e997aa2bb1924c4fe6990cce3e532201073d Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 30 May 2023 12:50:51 +1000 Subject: [PATCH] Fixed a potential crash after changing a property to be nullable --- .../libsession/messaging/jobs/RetrieveProfileAvatarJob.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/RetrieveProfileAvatarJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/RetrieveProfileAvatarJob.kt index 7ad76317de..5c617fbdb0 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/RetrieveProfileAvatarJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/RetrieveProfileAvatarJob.kt @@ -20,7 +20,7 @@ import java.io.FileOutputStream import java.io.InputStream import java.security.SecureRandom -class RetrieveProfileAvatarJob(val profileAvatar: String?, val recipientAddress: Address): Job { +class RetrieveProfileAvatarJob(private val profileAvatar: String?, private val recipientAddress: Address): Job { override var delegate: JobDelegate? = null override var id: String? = null override var failureCount: Int = 0 @@ -31,8 +31,8 @@ class RetrieveProfileAvatarJob(val profileAvatar: String?, val recipientAddress: val KEY: String = "RetrieveProfileAvatarJob" // Keys used for database storage - private val PROFILE_AVATAR_KEY = "profileAvatar" - private val RECEIPIENT_ADDRESS_KEY = "recipient" + private const val PROFILE_AVATAR_KEY = "profileAvatar" + private const val RECEIPIENT_ADDRESS_KEY = "recipient" } override fun execute(dispatcherName: String) { @@ -97,7 +97,7 @@ class RetrieveProfileAvatarJob(val profileAvatar: String?, val recipientAddress: class Factory: Job.Factory { override fun create(data: Data): RetrieveProfileAvatarJob { - val profileAvatar = data.getString(PROFILE_AVATAR_KEY) + val profileAvatar = if (data.hasString(PROFILE_AVATAR_KEY)) { data.getString(PROFILE_AVATAR_KEY) } else { null } val recipientAddress = Address.fromSerialized(data.getString(RECEIPIENT_ADDRESS_KEY)) return RetrieveProfileAvatarJob(profileAvatar, recipientAddress) }