Browse Source

Avoid dropping messages with missing ciphertext on the floor

- When messages are lacking in ciphertext (it needs to be reencoded for
  us), WA will send us a message stub (which we don't process, and need
  to).
- This then leads to us getting an empty message content, eating it
  to avoid saying something useless, storing the msgid, and then not
  sending the real message content later!
- This fixes that by checking we're actually sending something before
  storing.
  (It's only a short-term fix really though.)
master
eta 3 years ago
parent
commit
c8d64e6cae
  1. 2
      Cargo.lock
  2. 14
      src/whatsapp.rs

2
Cargo.lock generated

@ -2545,7 +2545,7 @@ dependencies = [ @@ -2545,7 +2545,7 @@ dependencies = [
[[package]]
name = "whatsappweb-eta"
version = "0.5.0-pre1"
source = "git+https://git.theta.eu.org/whatsappweb-rs.git/#e0af8589e1ed3b8622c166e9facee19c563c906e"
source = "git+https://git.theta.eu.org/whatsappweb-rs.git/#1769795e6853de519bb8e2923890b1cf69d12636"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",

14
src/whatsapp.rs

@ -406,10 +406,22 @@ impl WhatsappManager { @@ -406,10 +406,22 @@ impl WhatsappManager {
from, group, content, quoted
};
let (msgs, is_media) = self.msgproc.process_wa_incoming(inc)?;
let num_msgs = msgs.len();
for msg in msgs {
self.store_message(&msg.from, &msg.text, msg.group, msg.ts)?;
}
if !is_media {
// The > 0 check is here to avoid us storing a message ID when we actually never
// got the message, because it was sent as a missing-ciphertext stub earlier or
// something.
//
// Either way, we want to ensure that we send *something* for each message we're
// marking as seen! Otherwise things get dropped on the floor.
//
// (FIXME: actually expose this stub type in ww-rs and send it as an alert)
if num_msgs == 0 {
warn!("Message {} is empty (for now).", id.0);
}
else if !is_media {
self.store.store_wa_msgid(id.0.clone())?;
}
if let Some(p) = peer {

Loading…
Cancel
Save