whatsapp_rust/client/
context_impl.rs1use crate::client::Client;
2use async_trait::async_trait;
3use std::collections::HashMap;
4use wacore::client::context::{GroupInfo, SendContextResolver};
5use wacore::libsignal::protocol::PreKeyBundle;
6use wacore_binary::jid::Jid;
7
8#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
9#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
10impl SendContextResolver for Client {
11 async fn resolve_devices(&self, jids: &[Jid]) -> Result<Vec<Jid>, anyhow::Error> {
12 self.get_user_devices(jids).await
13 }
14
15 async fn fetch_prekeys(
16 &self,
17 jids: &[Jid],
18 ) -> Result<HashMap<Jid, PreKeyBundle>, anyhow::Error> {
19 self.fetch_pre_keys(jids, None).await
20 }
21
22 async fn fetch_prekeys_for_identity_check(
23 &self,
24 jids: &[Jid],
25 ) -> Result<HashMap<Jid, PreKeyBundle>, anyhow::Error> {
26 self.fetch_pre_keys(jids, Some("identity")).await
27 }
28
29 async fn resolve_group_info(&self, jid: &Jid) -> Result<GroupInfo, anyhow::Error> {
30 self.groups().query_info(jid).await
31 }
32
33 async fn get_lid_for_phone(&self, phone_user: &str) -> Option<String> {
34 self.lid_pn_cache.get_current_lid(phone_user).await
35 }
36}