From e0743ff2c31dad31eca7fd743d8b822a271e629c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de>
Date: Tue, 11 Jan 2022 19:08:53 +0100
Subject: [PATCH] Fix bug with empty introduction messages (causes
 IllegalArgumentException)

---
 .../briar/desktop/introduction/IntroductionViewModel.kt       | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/kotlin/org/briarproject/briar/desktop/introduction/IntroductionViewModel.kt b/src/main/kotlin/org/briarproject/briar/desktop/introduction/IntroductionViewModel.kt
index c49ea03c78..949eb46a2a 100644
--- a/src/main/kotlin/org/briarproject/briar/desktop/introduction/IntroductionViewModel.kt
+++ b/src/main/kotlin/org/briarproject/briar/desktop/introduction/IntroductionViewModel.kt
@@ -81,7 +81,9 @@ constructor(
     fun makeIntroduction() {
         val c1 = requireNotNull(_firstContact.value)
         val c2 = requireNotNull(_secondContact.value)
-        val msg = _introductionMessage.value
+        // It's important not to send the empty string here as briar's MessageEncoder for introduction messages throws
+        // an IllegalArgumentException in that case. It is however OK to pass null in this case.
+        val msg = _introductionMessage.value.ifEmpty { null }
 
         runOnDbThread {
             val c1 = contactManager.getContact(c1.idWrapper.contactId)
-- 
GitLab