imsd, engine: a received text records the subscriber it arrived for
The Messaging interface gave a received text with its sender and the service centre but not the subscriber it was for. A consumer completing a national-form sender with a country code had to take the code from the daemon's status at import time, which is the wrong moment: the daemon keeps a text on disk until an app deletes it, so the app that imports it after a SIM change knows only the new SIM's code, and a national number under the old SIM's plan is keyed, and replied to, under the new one — another subscriber. Only the daemon knows at receipt which subscriber a text arrived for. The stored record and the Received and List dictionaries carry it as `to`: the own number the daemon holds at the moment of receipt — the first tel: P-Associated-URI of this run's latest answer to a fresh registration, a resume or a reconnect that carried one (a periodic refresh's answer is not read for it) and, until the first such, the state file's once a resume attempt has taken it up. The key is absent while the daemon holds none. It is additive: an app that does not know it ignores it, and a record without it reads as before. The value comes from a header, so the emission makes it valid UTF-8, as it does a failed submission's reason. Tested: tests/Engine, the record round trip with `to` and a record without it.
This commit is contained in:
parent
910e2594a0
commit
04c615fc15
5 changed files with 24 additions and 12 deletions
|
|
@ -1673,6 +1673,7 @@ int main() {
|
|||
StoredSms r;
|
||||
r.id = "ims-sms-in-1792186043-7";
|
||||
r.receivedAt = 1792186043;
|
||||
r.to = "tel:+31612345678";
|
||||
r.sms.from = "KPN Service=\n\"x\"";
|
||||
r.sms.text = "Grüße ❤\nline two=three";
|
||||
r.sms.scts = "2026-10-16T22:50:00+02:00";
|
||||
|
|
@ -1687,11 +1688,11 @@ int main() {
|
|||
r.sms.data = {0xDE, 0xAD};
|
||||
r.sms.tpdu = {0x04, 0x0B, 0x91};
|
||||
const std::string text = FormatStoredSms(r);
|
||||
Check(text.starts_with("id=ims-sms-in-1792186043-7\nreceived=1792186043\nfrom=") && text.contains("\nport-dst=2948\nport-src=9200\n") && text.ends_with("\npdu=040b91\n") && !text.contains("Grüße"), "store: the record's shape, the text as hex");
|
||||
Check(text.starts_with("id=ims-sms-in-1792186043-7\nreceived=1792186043\nto=tel:+31612345678\nfrom=") && text.contains("\nport-dst=2948\nport-src=9200\n") && text.ends_with("\npdu=040b91\n") && !text.contains("Grüße"), "store: the record's shape, the text as hex");
|
||||
auto back = ParseStoredSms(text);
|
||||
Check(back && back->id == r.id && back->receivedAt == r.receivedAt && back->sms.from == r.sms.from && back->sms.text == r.sms.text && back->sms.scts == r.sms.scts && back->sms.sc == r.sms.sc && back->sms.msgClass == 0 && back->sms.pid == 0x40 && back->sms.dcs == 0x08 && back->sms.segments == 2 && back->sms.messageWaiting && back->sms.portDst == 2948 && back->sms.portSrc == 9200 && back->sms.data == r.sms.data && back->sms.tpdu == r.sms.tpdu, "store: a full record round-trips");
|
||||
Check(back && back->id == r.id && back->receivedAt == r.receivedAt && back->to == r.to && back->sms.from == r.sms.from && back->sms.text == r.sms.text && back->sms.scts == r.sms.scts && back->sms.sc == r.sms.sc && back->sms.msgClass == 0 && back->sms.pid == 0x40 && back->sms.dcs == 0x08 && back->sms.segments == 2 && back->sms.messageWaiting && back->sms.portDst == 2948 && back->sms.portSrc == 9200 && back->sms.data == r.sms.data && back->sms.tpdu == r.sms.tpdu, "store: a full record round-trips");
|
||||
auto minimal = ParseStoredSms("id=x\n");
|
||||
Check(minimal && minimal->id == "x" && minimal->receivedAt == 0 && !minimal->sms.msgClass && !minimal->sms.portDst && minimal->sms.segments == 1 && minimal->sms.text.empty(), "store: absent keys read as defaults");
|
||||
Check(minimal && minimal->id == "x" && minimal->receivedAt == 0 && minimal->to.empty() && !minimal->sms.msgClass && !minimal->sms.portDst && minimal->sms.segments == 1 && minimal->sms.text.empty(), "store: absent keys read as defaults");
|
||||
Check(!ParseStoredSms("received=5\nfrom=00\n"), "store: no id, no record");
|
||||
Check(!ParseStoredSms("id=x\ntext=zz\n"), "store: a malformed hex value, no record");
|
||||
Check(!ParseStoredSms("id=x\nreceived=soon\n"), "store: a malformed number, no record");
|
||||
|
|
|
|||
Loading…
Reference in a new issue