Fully normalize all recipient strings
This commit is contained in:
parent
3dd096cba6
commit
a8d05df1ab
2 changed files with 3 additions and 3 deletions
|
@ -19,7 +19,7 @@ class MessagesRepository(private val api: MessagesService) {
|
|||
|
||||
fun getRecipients(unitId: Int, role: Int = 2): Single<List<Recipient>> {
|
||||
return api.getRecipients(unitId, role).map { it.data }.map { res ->
|
||||
res.map { it.copy(shortName = it.name.normalizeRecipient().substringBeforeLast(" (")) }
|
||||
res.map { it.copy(shortName = it.name.normalizeRecipient()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class MessagesRepository(private val api: MessagesService) {
|
|||
}
|
||||
|
||||
private fun String.normalizeRecipient(): String {
|
||||
return this.substringBeforeLast("-").substringBefore(" [").trim()
|
||||
return this.substringBeforeLast("-").substringBefore(" [").substringBeforeLast(" (").trim()
|
||||
}
|
||||
|
||||
private fun getDate(date: LocalDateTime?): String {
|
||||
|
|
|
@ -105,7 +105,7 @@ class MessagesTest : BaseLocalTest() {
|
|||
server.start(3000)
|
||||
|
||||
api.getSentMessages(null, null).blockingGet()[5].run {
|
||||
assertEquals("Tracz Antoni (TA); Kowalska Joanna", recipient)
|
||||
assertEquals("Tracz Antoni; Kowalska Joanna", recipient)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue