SMS: fix displayed number on sent messages
This commit is contained in:
parent
3f3cdde53b
commit
2e3ce68e3d
3 changed files with 26 additions and 2 deletions
|
@ -26,6 +26,16 @@ class Sms {
|
|||
sent = true
|
||||
}
|
||||
|
||||
internal constructor(other: Sms, number: String? = null) {
|
||||
phoneNumber = number ?: other.phoneNumber
|
||||
text = other.text
|
||||
date = other.date
|
||||
received = other.received
|
||||
sent = other.sent
|
||||
processed = other.processed
|
||||
ignored = other.ignored
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "SMS from $phoneNumber: $text"
|
||||
}
|
||||
|
|
|
@ -1095,8 +1095,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
|
||||
private fun sendSMSToAllNumbers(sms: Sms) {
|
||||
for (number in allowedNumbers) {
|
||||
sms.phoneNumber = number
|
||||
sendSMS(sms)
|
||||
sendSMS(Sms(sms, number))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,5 +26,20 @@ class SmsTest : TestBase() {
|
|||
Assert.assertEquals(sms.text, "U")
|
||||
Assert.assertTrue(sms.sent)
|
||||
Assert.assertEquals(sms.toString(), "SMS from aNumber: U")
|
||||
|
||||
// copy constructor #1
|
||||
val sms2 = Sms(sms)
|
||||
Assert.assertEquals(sms2.phoneNumber, "aNumber")
|
||||
Assert.assertEquals(sms2.text, "U")
|
||||
Assert.assertTrue(sms2.sent)
|
||||
Assert.assertEquals(sms2.toString(), "SMS from aNumber: U")
|
||||
|
||||
// copy constructor #2
|
||||
val sms3 = Sms(sms, "different")
|
||||
Assert.assertEquals(sms3.phoneNumber, "different")
|
||||
Assert.assertEquals(sms3.text, "U")
|
||||
Assert.assertTrue(sms3.sent)
|
||||
Assert.assertEquals(sms3.toString(), "SMS from different: U")
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue