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
|
|
@ -1309,7 +1309,8 @@ export namespace imsd::engine {
|
|||
|
||||
// A received message as the daemon keeps it until an app takes it
|
||||
// (`List`/`Delete` on the Messaging interface, §8.4): its id, when it
|
||||
// arrived (epoch seconds) and the message. One record per file,
|
||||
// arrived (epoch seconds), the message and the subscriber it arrived
|
||||
// for. One record per file,
|
||||
// key=value lines; the sender, the text, the data and the PDU as hex
|
||||
// (a sender or a text may hold any character). Absent keys read as
|
||||
// their defaults; a record without an id, or with a number or hex
|
||||
|
|
@ -1318,6 +1319,7 @@ export namespace imsd::engine {
|
|||
std::string id;
|
||||
std::int64_t receivedAt = 0;
|
||||
SmsReceived sms;
|
||||
std::string to; // the own number the daemon held at receipt (from a tel: P-Associated-URI); "" while it held none
|
||||
};
|
||||
|
||||
std::string FormatStoredSms(const StoredSms& r) {
|
||||
|
|
@ -1325,6 +1327,7 @@ export namespace imsd::engine {
|
|||
std::string out;
|
||||
out += std::format("id={}\n", r.id);
|
||||
out += std::format("received={}\n", r.receivedAt);
|
||||
if (!r.to.empty()) out += std::format("to={}\n", r.to);
|
||||
out += std::format("from={}\n", hex(r.sms.from));
|
||||
out += std::format("sc={}\n", r.sms.sc);
|
||||
out += std::format("timestamp={}\n", r.sms.scts);
|
||||
|
|
@ -1377,6 +1380,7 @@ export namespace imsd::engine {
|
|||
std::string_view v = line.substr(eq + 1);
|
||||
if (k == "id") r.id = std::string(v);
|
||||
else if (k == "received") r.receivedAt = intOf(v);
|
||||
else if (k == "to") r.to = std::string(v);
|
||||
else if (k == "from") r.sms.from = stringOf(v);
|
||||
else if (k == "sc") r.sms.sc = std::string(v);
|
||||
else if (k == "timestamp") r.sms.scts = std::string(v);
|
||||
|
|
|
|||
Loading…
Reference in a new issue