File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
src/main/kotlin/com/wire/bots/application Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,9 @@ object EventMapper {
3030 val senderId = eventDTO.userId?.let {
3131 QualifiedId (UUID .fromString(it), " " )
3232 }
33- // basic validation if it is a UUID, it means it is a reminder id
34- if (isUUID(buttonId)) {
33+
34+ val parsedUuid = runCatching { UUID .fromString(buttonId) }.getOrNull()
35+ if (parsedUuid != null ) {
3536 Command
3637 .DeleteReminder (
3738 conversationId = eventDTO.conversationId,
@@ -40,8 +41,6 @@ object EventMapper {
4041 senderId = senderId
4142 ).right()
4243 } else {
43- // It was not a UUID, so it's not a delete action.
44- // We can parse it as a normal command in case other button actions are added in the future.
4544 parseCommand(
4645 conversationId = eventDTO.conversationId,
4746 rawCommand = buttonId,
@@ -174,11 +173,6 @@ object EventMapper {
174173 }
175174}
176175
177- private val UUID_REGEX =
178- " ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" .toRegex()
179-
180- private fun isUUID (text : String ): Boolean = UUID_REGEX .matches(text)
181-
182176internal val COMMAND_EXPRESSION : Regex = " \\ s+" .toRegex()
183177internal val COMMAND_HINT =
184178 """
You can’t perform that action at this time.
0 commit comments