-
-
Notifications
You must be signed in to change notification settings - Fork 127
feat: cstoken (NCT) privacy token fallback + proto update #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fc6b868
db309c7
2d86cd8
af01531
6625661
9985b63
b088193
f5cbef6
99c3d72
b078011
95c4daf
8cb0f7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,35 @@ impl<'a> Contacts<'a> { | |||||||||||||
| Self { client } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| async fn persist_lid_mappings<'b, I>(&self, entries: I) | ||||||||||||||
| where | ||||||||||||||
| I: IntoIterator<Item = (&'b Jid, Option<&'b Jid>)>, | ||||||||||||||
| { | ||||||||||||||
| for (jid, lid) in entries { | ||||||||||||||
| let Some(lid) = lid else { | ||||||||||||||
| continue; | ||||||||||||||
| }; | ||||||||||||||
| if !jid.is_pn() || !lid.is_lid() { | ||||||||||||||
| continue; | ||||||||||||||
| } | ||||||||||||||
| if let Err(err) = self | ||||||||||||||
| .client | ||||||||||||||
| .add_lid_pn_mapping( | ||||||||||||||
| &lid.user, | ||||||||||||||
| &jid.user, | ||||||||||||||
| crate::lid_pn_cache::LearningSource::Usync, | ||||||||||||||
| ) | ||||||||||||||
|
Comment on lines
+36
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Enforce PN/LID validation in the persistence API, not only at this callsite. This helper filters invalid pairs, but other write paths ( 🤖 Prompt for AI Agents |
||||||||||||||
| .await | ||||||||||||||
| { | ||||||||||||||
| log::warn!( | ||||||||||||||
| "Failed to persist usync LID mapping {} -> {}: {err}", | ||||||||||||||
| jid, | ||||||||||||||
| lid | ||||||||||||||
| ); | ||||||||||||||
|
Comment on lines
+48
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redact JIDs in warning logs to avoid identifier leakage. Line 49 logs full Suggested fix- log::warn!(
- "Failed to persist usync LID mapping {} -> {}: {err}",
- jid,
- lid
- );
+ log::warn!("Failed to persist usync LID mapping (jid/lid redacted): {err}");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| pub async fn is_on_whatsapp(&self, phones: &[&str]) -> Result<Vec<IsOnWhatsAppResult>> { | ||||||||||||||
| if phones.is_empty() { | ||||||||||||||
| return Ok(Vec::new()); | ||||||||||||||
|
|
@@ -50,7 +79,10 @@ impl<'a> Contacts<'a> { | |||||||||||||
| let phone_strings: Vec<String> = phones.iter().map(|s| s.to_string()).collect(); | ||||||||||||||
| let spec = ContactInfoSpec::new(phone_strings, request_id); | ||||||||||||||
|
|
||||||||||||||
| Ok(self.client.execute(spec).await?) | ||||||||||||||
| let info = self.client.execute(spec).await?; | ||||||||||||||
| self.persist_lid_mappings(info.iter().map(|entry| (&entry.jid, entry.lid.as_ref()))) | ||||||||||||||
| .await; | ||||||||||||||
| Ok(info) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| pub async fn get_profile_picture( | ||||||||||||||
|
|
@@ -98,7 +130,10 @@ impl<'a> Contacts<'a> { | |||||||||||||
| let request_id = self.client.generate_request_id(); | ||||||||||||||
| let spec = UserInfoSpec::new(jids.to_vec(), request_id); | ||||||||||||||
|
|
||||||||||||||
| Ok(self.client.execute(spec).await?) | ||||||||||||||
| let info = self.client.execute(spec).await?; | ||||||||||||||
| self.persist_lid_mappings(info.values().map(|entry| (&entry.jid, entry.lid.as_ref()))) | ||||||||||||||
| .await; | ||||||||||||||
| Ok(info) | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cancel pending sent-node waiters on disconnect.
These waiters are transport-scoped, but
cleanup_connection_state()never drops them. If the socket dies before a match arrives, the receiver can stay pending across reconnects and then resolve against a later stanza from the wrong connection.Suggested cleanup
async fn cleanup_connection_state(&self) { + { + let mut waiters = self + .sent_node_waiters + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + if !waiters.is_empty() { + waiters.clear(); // dropping senders cancels receivers + self.sent_node_waiter_count.store(0, Ordering::Release); + } + } + self.is_logged_in.store(false, Ordering::Relaxed); self.is_ready.store(false, Ordering::Relaxed);Also applies to: 593-594, 2994-3011, 3037-3055, 3208-3210
🤖 Prompt for AI Agents