aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreta <hi@theta.eu.org>2019-11-07 21:39:33 +0000
committereta <hi@theta.eu.org>2019-11-07 21:44:49 +0000
commitc8d64e6cae752f898e9f7b269c47b4e2af131306 (patch)
tree4d7ee499fd46242d5313a4019958043eb1307e83
parent891b50415abaf8a52d05dcdee23e116edc1a6984 (diff)
downloadsms-irc-c8d64e6cae752f898e9f7b269c47b4e2af131306.tar.gz
sms-irc-c8d64e6cae752f898e9f7b269c47b4e2af131306.tar.bz2
sms-irc-c8d64e6cae752f898e9f7b269c47b4e2af131306.zip
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.)
-rw-r--r--Cargo.lock2
-rw-r--r--src/whatsapp.rs14
2 files changed, 14 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4bb432d..d487d5c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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)",
diff --git a/src/whatsapp.rs b/src/whatsapp.rs
index 3f2da80..542742d 100644
--- a/src/whatsapp.rs
+++ b/src/whatsapp.rs
@@ -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 {