From 5c55e23e050a10cd1d819f2555ffac694df140de Mon Sep 17 00:00:00 2001 From: MarianKijewski Date: Sat, 17 Jan 2026 20:05:59 +0100 Subject: [PATCH 1/2] apply common welcome message structure --- .../polls/services/UserCommunicationService.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt b/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt index 12b61ca..df46e04 100644 --- a/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt +++ b/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt @@ -22,13 +22,12 @@ class UserCommunicationService( private val version: String ) { private companion object : KLogging() { + const val WELCOME_TEXT = + "👋 Hi, I'm the Poll App. Thanks for adding me to the conversation.\n" + + "You can use me to create polls directly in Wire.\n" + + "I'm here to help make everyday work a little easier." const val USAGE = "To create poll please text: " + "`/poll \"Question\" \"Option 1\" \"Option 2\"`. To display usage write `/poll help`" - val commands = """ - Following commands are available: - `/poll "Question" "Option 1" "Option 2"` will create poll - `/poll help` to show help - """.trimIndent() } /** @@ -38,7 +37,12 @@ class UserCommunicationService( manager: WireApplicationManager, conversationId: QualifiedId ) { - manager.send(textMessage(conversationId, "Hello, I'm Poll App. $USAGE")) + val message = buildString { + appendLine(WELCOME_TEXT) + append(USAGE) + } + + manager.send(textMessage(conversationId, message)) logger.info("App sent a welcome message. conversationId: $conversationId") } @@ -69,7 +73,7 @@ class UserCommunicationService( manager: WireApplicationManager, conversationId: QualifiedId ) { - manager.send(textMessage(conversationId, commands)) + manager.send(textMessage(conversationId, USAGE)) } /** From a58f208e11892b0b0a1ca3527ac0fcc86096fc6d Mon Sep 17 00:00:00 2001 From: MarianKijewski Date: Sun, 18 Jan 2026 14:34:07 +0100 Subject: [PATCH 2/2] build welcome text message just once and not every time it's used --- .../apps/polls/services/UserCommunicationService.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt b/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt index df46e04..f935bea 100644 --- a/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt +++ b/src/main/kotlin/com/wire/apps/polls/services/UserCommunicationService.kt @@ -22,12 +22,14 @@ class UserCommunicationService( private val version: String ) { private companion object : KLogging() { - const val WELCOME_TEXT = + private const val WELCOME_TEXT = "👋 Hi, I'm the Poll App. Thanks for adding me to the conversation.\n" + "You can use me to create polls directly in Wire.\n" + - "I'm here to help make everyday work a little easier." + "I'm here to help make everyday work a little easier.\n" const val USAGE = "To create poll please text: " + "`/poll \"Question\" \"Option 1\" \"Option 2\"`. To display usage write `/poll help`" + + const val WELCOME_MESSAGE = WELCOME_TEXT + USAGE } /** @@ -37,12 +39,7 @@ class UserCommunicationService( manager: WireApplicationManager, conversationId: QualifiedId ) { - val message = buildString { - appendLine(WELCOME_TEXT) - append(USAGE) - } - - manager.send(textMessage(conversationId, message)) + manager.send(textMessage(conversationId, WELCOME_MESSAGE)) logger.info("App sent a welcome message. conversationId: $conversationId") }