@@ -105,6 +105,7 @@ import io.realm.kotlin.ext.copyFromRealm
105105import io.realm.kotlin.ext.realmListOf
106106import io.realm.kotlin.ext.toRealmList
107107import io.realm.kotlin.types.RealmList
108+ import io.sentry.Breadcrumb
108109import io.sentry.Sentry
109110import kotlinx.coroutines.CompletableJob
110111import kotlinx.coroutines.CoroutineDispatcher
@@ -363,8 +364,13 @@ class NewMessageViewModel @Inject constructor(
363364 val quote = draftInitManager.createQuote(draftMode, fullMessage, draft.attachments)
364365 if (quote != null ) initialQuote = quote
365366
367+ if (fullMessage.body == null ) {
368+ SentryLog .e(TAG , " The message we're trying to reply to has an unexpected null body" ) { scope ->
369+ scope.addBreadcrumb(Breadcrumb .info(" message resource: ${fullMessage.resource} " ))
370+ }
371+ }
366372 val isAiEnabled = currentMailbox().featureFlags.contains(FeatureFlag .AI )
367- if (isAiEnabled) parsePreviousMailToAnswerWithAi(fullMessage.body!! )
373+ if (isAiEnabled) parsePreviousMailToAnswerWithAi(fullMessage.body)
368374
369375 val isEncryptionEnabled = currentMailbox().featureFlags.contains(FeatureFlag .ENCRYPTION )
370376 if (isEncryptionEnabled) draft.isEncrypted = fullMessage.isEncrypted
@@ -567,9 +573,9 @@ class NewMessageViewModel @Inject constructor(
567573 }
568574 }
569575
570- private suspend fun parsePreviousMailToAnswerWithAi (previousMessageBody : Body ) {
576+ private suspend fun parsePreviousMailToAnswerWithAi (previousMessageBody : Body ? ) {
571577 if (draftMode == DraftMode .REPLY || draftMode == DraftMode .REPLY_ALL ) {
572- aiSharedData.previousMessageBodyPlainText = previousMessageBody.asPlainText()
578+ aiSharedData.previousMessageBodyPlainText = previousMessageBody? .asPlainText()
573579 }
574580 }
575581
0 commit comments