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
|
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 {
|
override fun toString(): String {
|
||||||
return "SMS from $phoneNumber: $text"
|
return "SMS from $phoneNumber: $text"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1095,8 +1095,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
|
|
||||||
private fun sendSMSToAllNumbers(sms: Sms) {
|
private fun sendSMSToAllNumbers(sms: Sms) {
|
||||||
for (number in allowedNumbers) {
|
for (number in allowedNumbers) {
|
||||||
sms.phoneNumber = number
|
sendSMS(Sms(sms, number))
|
||||||
sendSMS(sms)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,5 +26,20 @@ class SmsTest : TestBase() {
|
||||||
Assert.assertEquals(sms.text, "U")
|
Assert.assertEquals(sms.text, "U")
|
||||||
Assert.assertTrue(sms.sent)
|
Assert.assertTrue(sms.sent)
|
||||||
Assert.assertEquals(sms.toString(), "SMS from aNumber: U")
|
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