diff --git a/src/comms.rs b/src/comms.rs index 8d19bbca..db75a30a 100644 --- a/src/comms.rs +++ b/src/comms.rs @@ -54,6 +54,7 @@ pub enum ToMinionPayload { Shutdown, SubscribeGeneralFeed(Vec), SubscribeMentions, + SubscribeConfig, SubscribePersonFeed(PublicKeyHex), SubscribeThreadFeed(IdHex, Vec), TempSubscribeMetadata(Vec), diff --git a/src/overlord/minion/mod.rs b/src/overlord/minion/mod.rs index db1b8c1e..c0a744c5 100644 --- a/src/overlord/minion/mod.rs +++ b/src/overlord/minion/mod.rs @@ -299,6 +299,9 @@ impl Minion { ToMinionPayload::SubscribeMentions => { self.subscribe_mentions().await?; } + ToMinionPayload::SubscribeConfig => { + self.subscribe_config().await?; + } ToMinionPayload::SubscribePersonFeed(pubkeyhex) => { self.subscribe_person_feed(pubkeyhex).await?; } @@ -530,25 +533,11 @@ impl Minion { let pkh: PublicKeyHex = pubkey.into(); filters.push(Filter { - p: vec![pkh.clone()], + p: vec![pkh], kinds, since: Some(replies_since), ..Default::default() }); - - // Listen for my metadata and similar kinds of posts - // FIXME - move this to listening to my WRITE relays - filters.push(Filter { - authors: vec![pkh.into()], - kinds: vec![ - EventKind::Metadata, - EventKind::RecommendRelay, - EventKind::ContactList, - EventKind::RelayList, - ], - since: Some(replies_since), - ..Default::default() - }); } self.subscribe(filters, "mentions_feed").await?; @@ -568,6 +557,29 @@ impl Minion { Ok(()) } + // Subscribe to the user's config which is on their own write relays + async fn subscribe_config(&mut self) -> Result<(), Error> { + if let Some(pubkey) = GLOBALS.signer.public_key() { + let pkh: PublicKeyHex = pubkey.into(); + + let filters: Vec = vec![Filter { + authors: vec![pkh.into()], + kinds: vec![ + EventKind::Metadata, + //EventKind::RecommendRelay, + EventKind::ContactList, + EventKind::RelayList, + ], + // these are all replaceable, no since required + ..Default::default() + }]; + + self.subscribe(filters, "config_feed").await?; + } + + Ok(()) + } + // Subscribe to the posts a person generates on the relays they write to async fn subscribe_person_feed(&mut self, pubkey: PublicKeyHex) -> Result<(), Error> { // NOTE we do not unsubscribe to the general feed diff --git a/src/overlord/mod.rs b/src/overlord/mod.rs index 7e040078..740c6d6f 100644 --- a/src/overlord/mod.rs +++ b/src/overlord/mod.rs @@ -218,7 +218,22 @@ impl Overlord { self.pick_relays().await; } - // For NIP-65, separately subscribe to our mentions on our read relays + // Separately subscribe to our config on our write relays + let write_relay_urls: Vec = GLOBALS.relays_url_filtered(|r| r.write); + for relay_url in write_relay_urls.iter() { + // Start a minion for this relay if there is none + if !GLOBALS.relay_is_connected(relay_url) { + self.start_minion(relay_url.clone()).await?; + } + + // Subscribe to our mentions + let _ = self.to_minions.send(ToMinionMessage { + target: relay_url.to_string(), + payload: ToMinionPayload::SubscribeConfig, + }); + } + + // Separately subscribe to our mentions on our read relays let read_relay_urls: Vec = GLOBALS.relays_url_filtered(|r| r.read); for relay_url in read_relay_urls.iter() { // Start a minion for this relay if there is none