diff --git a/crates/core/src/connection.rs b/crates/core/src/connection.rs index 1724055..61a3607 100644 --- a/crates/core/src/connection.rs +++ b/crates/core/src/connection.rs @@ -1346,18 +1346,25 @@ impl ConnectionManager { conn: iroh::endpoint::Connection, storage: &Arc, peer_id: &NodeId, - our_node_id: NodeId, + _our_node_id: NodeId, ) -> anyhow::Result { - let (our_follows, follows_sync) = { + let (our_follows, follows_sync, our_personas) = { let s = storage.get().await; - (s.list_follows()?, s.get_follows_with_last_sync().unwrap_or_default()) + ( + s.list_follows()?, + s.get_follows_with_last_sync().unwrap_or_default(), + s.list_posting_identities().unwrap_or_default(), + ) }; - // Merged pull: include our own NodeId in the query so the peer returns - // posts where we're either a followed author OR a recipient (DM). + // Merged pull: include every posting identity we hold so DMs to any + // of our personas match via wrapped_key.recipient. Network NodeId is + // never an author or recipient and would never match. let mut query_list = our_follows; - if !query_list.contains(&our_node_id) { - query_list.push(our_node_id); + for pi in &our_personas { + if !query_list.contains(&pi.node_id) { + query_list.push(pi.node_id); + } } let request = PullSyncRequestPayload { @@ -1911,18 +1918,21 @@ impl ConnectionManager { }, }; - let (our_follows, follows_sync) = { + let (our_follows, follows_sync, our_personas) = { let storage = self.storage.get().await; ( storage.list_follows()?, storage.get_follows_with_last_sync().unwrap_or_default(), + storage.list_posting_identities().unwrap_or_default(), ) }; - // Merged pull: include our own NodeId in the query list. + // Merged pull: include every posting identity so DMs match recipient. let mut query_list = our_follows; - if !query_list.contains(&self.our_node_id) { - query_list.push(self.our_node_id); + for pi in &our_personas { + if !query_list.contains(&pi.node_id) { + query_list.push(pi.node_id); + } } let (mut send, mut recv) = pull_conn.open_bi().await?; @@ -2009,18 +2019,21 @@ impl ConnectionManager { .get(peer_id) .ok_or_else(|| anyhow::anyhow!("not connected to {}", hex::encode(peer_id)))?; - let (our_follows, follows_sync) = { + let (our_follows, follows_sync, our_personas) = { let storage = self.storage.get().await; ( storage.list_follows()?, storage.get_follows_with_last_sync().unwrap_or_default(), + storage.list_posting_identities().unwrap_or_default(), ) }; - // Merged pull: include our own NodeId in the query list. + // Merged pull: include every posting identity so DMs match recipient. let mut query_list = our_follows; - if !query_list.contains(&self.our_node_id) { - query_list.push(self.our_node_id); + for pi in &our_personas { + if !query_list.contains(&pi.node_id) { + query_list.push(pi.node_id); + } } let request = PullSyncRequestPayload { diff --git a/crates/core/src/network.rs b/crates/core/src/network.rs index cf87b52..8bdd73f 100644 --- a/crates/core/src/network.rs +++ b/crates/core/src/network.rs @@ -1713,17 +1713,23 @@ impl Network { /// Pull posts from a peer (persistent if available, ephemeral otherwise). pub async fn pull_from_peer(&self, peer_id: &NodeId) -> anyhow::Result { let conn = self.get_connection(peer_id).await?; - let (our_follows, follows_sync) = { + let (our_follows, follows_sync, our_personas) = { let storage = self.storage.get().await; ( storage.list_follows()?, storage.get_follows_with_last_sync().unwrap_or_default(), + storage.list_posting_identities().unwrap_or_default(), ) }; - // Merged pull: include our own NodeId so DMs addressed to us match. + // Merged pull: include every posting identity we hold so DMs addressed + // to any of our personas match on recipient. Our network NodeId is + // never an author nor a wrapped_key recipient — including it would + // never match and would leak the network↔posting boundary. let mut query_list = our_follows; - if !query_list.contains(&self.our_node_id) { - query_list.push(self.our_node_id); + for pi in &our_personas { + if !query_list.contains(&pi.node_id) { + query_list.push(pi.node_id); + } } let (mut send, mut recv) = conn.open_bi().await?; write_typed_message(