mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
redo start_long_lived_subscriptions after the wizard completes so people don't need to restart
This commit is contained in:
parent
b6e19360b9
commit
3e276803aa
@ -3,7 +3,7 @@ use crate::ui::{GossipUi, Page};
|
|||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::{Context, RichText, Ui};
|
use egui::{Context, RichText, Ui};
|
||||||
use gossip_lib::comms::ToOverlordMessage;
|
use gossip_lib::comms::ToOverlordMessage;
|
||||||
use gossip_lib::{FeedKind, Person, PersonList, GLOBALS};
|
use gossip_lib::{Person, PersonList, GLOBALS};
|
||||||
use gossip_relay_picker::Direction;
|
use gossip_relay_picker::Direction;
|
||||||
use nostr_types::{Profile, PublicKey};
|
use nostr_types::{Profile, PublicKey};
|
||||||
|
|
||||||
@ -153,8 +153,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
|||||||
.to_overlord
|
.to_overlord
|
||||||
.send(ToOverlordMessage::PushPersonList(PersonList::Followed));
|
.send(ToOverlordMessage::PushPersonList(PersonList::Followed));
|
||||||
|
|
||||||
let _ = GLOBALS.storage.set_flag_wizard_complete(true, None);
|
super::complete_wizard(app);
|
||||||
app.page = Page::Feed(FeedKind::List(PersonList::Followed, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(20.0);
|
ui.add_space(20.0);
|
||||||
@ -163,16 +162,14 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
|||||||
label = label.color(app.theme.accent_color());
|
label = label.color(app.theme.accent_color());
|
||||||
}
|
}
|
||||||
if ui.button(label).clicked() {
|
if ui.button(label).clicked() {
|
||||||
let _ = GLOBALS.storage.set_flag_wizard_complete(true, None);
|
super::complete_wizard(app);
|
||||||
app.page = Page::Feed(FeedKind::List(PersonList::Followed, false));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ui.add_space(20.0);
|
ui.add_space(20.0);
|
||||||
let mut label = RichText::new(" > Finish");
|
let mut label = RichText::new(" > Finish");
|
||||||
label = label.color(app.theme.accent_color());
|
label = label.color(app.theme.accent_color());
|
||||||
if ui.button(label).clicked() {
|
if ui.button(label).clicked() {
|
||||||
let _ = GLOBALS.storage.set_flag_wizard_complete(true, None);
|
super::complete_wizard(app);
|
||||||
app.page = Page::Feed(FeedKind::List(PersonList::Followed, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ use crate::ui::{GossipUi, Page};
|
|||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::widgets::{Button, Slider};
|
use egui::widgets::{Button, Slider};
|
||||||
use egui::{Align, Context, Layout};
|
use egui::{Align, Context, Layout};
|
||||||
|
use gossip_lib::comms::ToOverlordMessage;
|
||||||
use gossip_lib::{FeedKind, PersonList, Relay, GLOBALS};
|
use gossip_lib::{FeedKind, PersonList, Relay, GLOBALS};
|
||||||
|
|
||||||
mod follow_people;
|
mod follow_people;
|
||||||
@ -198,8 +199,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
|||||||
ui.add_space(20.0);
|
ui.add_space(20.0);
|
||||||
if wp != WizardPage::FollowPeople {
|
if wp != WizardPage::FollowPeople {
|
||||||
if ui.button(" X Exit this Wizard").clicked() {
|
if ui.button(" X Exit this Wizard").clicked() {
|
||||||
let _ = GLOBALS.storage.set_flag_wizard_complete(true, None);
|
complete_wizard(app);
|
||||||
app.page = Page::Feed(FeedKind::List(PersonList::Followed, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,3 +264,15 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn complete_wizard(app: &mut GossipUi) {
|
||||||
|
let _ = GLOBALS.storage.set_flag_wizard_complete(true, None);
|
||||||
|
app.page = Page::Feed(FeedKind::List(PersonList::Followed, false));
|
||||||
|
|
||||||
|
// Once the wizard is complete, we need to tell the overlord to re-run
|
||||||
|
// its startup stuff, because we now have configuration that matters, and
|
||||||
|
// this way people don't have to restart gossip
|
||||||
|
let _ = GLOBALS
|
||||||
|
.to_overlord
|
||||||
|
.send(ToOverlordMessage::StartLongLivedSubscriptions);
|
||||||
|
}
|
||||||
|
@ -138,6 +138,9 @@ pub enum ToOverlordMessage {
|
|||||||
/// internal
|
/// internal
|
||||||
SetDmChannel(DmChannel),
|
SetDmChannel(DmChannel),
|
||||||
|
|
||||||
|
/// Calls [start_long_lived_subscriptions](crate::Overlord::start_long_lived_subscriptions)
|
||||||
|
StartLongLivedSubscriptions,
|
||||||
|
|
||||||
/// Calls [subscribe_config](crate::Overlord::subscribe_config)
|
/// Calls [subscribe_config](crate::Overlord::subscribe_config)
|
||||||
SubscribeConfig(RelayUrl),
|
SubscribeConfig(RelayUrl),
|
||||||
|
|
||||||
|
@ -177,66 +177,11 @@ impl Overlord {
|
|||||||
// Start periodic tasks in people manager (after signer)
|
// Start periodic tasks in people manager (after signer)
|
||||||
crate::people::People::start();
|
crate::people::People::start();
|
||||||
|
|
||||||
// FIXME - if this needs doing, it should be done dynamically as
|
|
||||||
// new people are encountered, not batch-style on startup.
|
|
||||||
// Create a person record for every person seen
|
|
||||||
|
|
||||||
// Initialize the relay picker
|
// Initialize the relay picker
|
||||||
GLOBALS.relay_picker.init().await?;
|
GLOBALS.relay_picker.init().await?;
|
||||||
|
|
||||||
// Pick Relays and start Minions
|
// Do the startup procedures
|
||||||
if !GLOBALS.storage.read_setting_offline() {
|
self.start_long_lived_subscriptions().await?;
|
||||||
self.pick_relays().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Separately subscribe to RelayList discovery for everyone we follow
|
|
||||||
// We just do this once at startup. Relay lists don't change that frequently.
|
|
||||||
let followed = GLOBALS.people.get_subscribed_pubkeys();
|
|
||||||
self.subscribe_discover(followed, None).await?;
|
|
||||||
|
|
||||||
// Separately subscribe to our outbox events on our write relays
|
|
||||||
let write_relay_urls: Vec<RelayUrl> = GLOBALS
|
|
||||||
.storage
|
|
||||||
.filter_relays(|r| r.has_usage_bits(Relay::WRITE) && r.rank != 0)?
|
|
||||||
.iter()
|
|
||||||
.map(|relay| relay.url.clone())
|
|
||||||
.collect();
|
|
||||||
for relay_url in write_relay_urls.iter() {
|
|
||||||
self.engage_minion(
|
|
||||||
relay_url.to_owned(),
|
|
||||||
vec![RelayJob {
|
|
||||||
reason: RelayConnectionReason::Config,
|
|
||||||
payload: ToMinionPayload {
|
|
||||||
job_id: rand::random::<u64>(),
|
|
||||||
detail: ToMinionPayloadDetail::SubscribeOutbox,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Separately subscribe to our mentions on our read relays
|
|
||||||
// NOTE: we also do this on all dynamically connected relays since NIP-65 is
|
|
||||||
// not in widespread usage.
|
|
||||||
let read_relay_urls: Vec<RelayUrl> = GLOBALS
|
|
||||||
.storage
|
|
||||||
.filter_relays(|r| r.has_usage_bits(Relay::READ) && r.rank != 0)?
|
|
||||||
.iter()
|
|
||||||
.map(|relay| relay.url.clone())
|
|
||||||
.collect();
|
|
||||||
for relay_url in read_relay_urls.iter() {
|
|
||||||
self.engage_minion(
|
|
||||||
relay_url.to_owned(),
|
|
||||||
vec![RelayJob {
|
|
||||||
reason: RelayConnectionReason::FetchMentions,
|
|
||||||
payload: ToMinionPayload {
|
|
||||||
job_id: rand::random::<u64>(),
|
|
||||||
detail: ToMinionPayloadDetail::SubscribeMentions,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
'mainloop: loop {
|
'mainloop: loop {
|
||||||
if let Err(e) = self.loop_handler().await {
|
if let Err(e) = self.loop_handler().await {
|
||||||
@ -684,6 +629,9 @@ impl Overlord {
|
|||||||
ToOverlordMessage::SetDmChannel(dmchannel) => {
|
ToOverlordMessage::SetDmChannel(dmchannel) => {
|
||||||
self.set_dm_channel(dmchannel).await?;
|
self.set_dm_channel(dmchannel).await?;
|
||||||
}
|
}
|
||||||
|
ToOverlordMessage::StartLongLivedSubscriptions => {
|
||||||
|
self.start_long_lived_subscriptions().await?;
|
||||||
|
}
|
||||||
ToOverlordMessage::SubscribeConfig(relay_url) => {
|
ToOverlordMessage::SubscribeConfig(relay_url) => {
|
||||||
self.subscribe_config(relay_url).await?;
|
self.subscribe_config(relay_url).await?;
|
||||||
}
|
}
|
||||||
@ -2372,6 +2320,65 @@ impl Overlord {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is done at startup and after the wizard.
|
||||||
|
pub async fn start_long_lived_subscriptions(&mut self) -> Result<(), Error> {
|
||||||
|
// Pick Relays and start Minions
|
||||||
|
if !GLOBALS.storage.read_setting_offline() {
|
||||||
|
self.pick_relays().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separately subscribe to RelayList discovery for everyone we follow
|
||||||
|
// We just do this once at startup. Relay lists don't change that frequently.
|
||||||
|
let followed = GLOBALS.people.get_subscribed_pubkeys();
|
||||||
|
self.subscribe_discover(followed, None).await?;
|
||||||
|
|
||||||
|
// Separately subscribe to our outbox events on our write relays
|
||||||
|
let write_relay_urls: Vec<RelayUrl> = GLOBALS
|
||||||
|
.storage
|
||||||
|
.filter_relays(|r| r.has_usage_bits(Relay::WRITE) && r.rank != 0)?
|
||||||
|
.iter()
|
||||||
|
.map(|relay| relay.url.clone())
|
||||||
|
.collect();
|
||||||
|
for relay_url in write_relay_urls.iter() {
|
||||||
|
self.engage_minion(
|
||||||
|
relay_url.to_owned(),
|
||||||
|
vec![RelayJob {
|
||||||
|
reason: RelayConnectionReason::Config,
|
||||||
|
payload: ToMinionPayload {
|
||||||
|
job_id: rand::random::<u64>(),
|
||||||
|
detail: ToMinionPayloadDetail::SubscribeOutbox,
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separately subscribe to our mentions on our read relays
|
||||||
|
// NOTE: we also do this on all dynamically connected relays since NIP-65 is
|
||||||
|
// not in widespread usage.
|
||||||
|
let read_relay_urls: Vec<RelayUrl> = GLOBALS
|
||||||
|
.storage
|
||||||
|
.filter_relays(|r| r.has_usage_bits(Relay::READ) && r.rank != 0)?
|
||||||
|
.iter()
|
||||||
|
.map(|relay| relay.url.clone())
|
||||||
|
.collect();
|
||||||
|
for relay_url in read_relay_urls.iter() {
|
||||||
|
self.engage_minion(
|
||||||
|
relay_url.to_owned(),
|
||||||
|
vec![RelayJob {
|
||||||
|
reason: RelayConnectionReason::FetchMentions,
|
||||||
|
payload: ToMinionPayload {
|
||||||
|
job_id: rand::random::<u64>(),
|
||||||
|
detail: ToMinionPayloadDetail::SubscribeMentions,
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Subscribe to the user's configuration events from the given relay
|
/// Subscribe to the user's configuration events from the given relay
|
||||||
pub async fn subscribe_config(&mut self, relay_url: RelayUrl) -> Result<(), Error> {
|
pub async fn subscribe_config(&mut self, relay_url: RelayUrl) -> Result<(), Error> {
|
||||||
self.engage_minion(
|
self.engage_minion(
|
||||||
|
19
gossip.log.txt
Normal file
19
gossip.log.txt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[2m2023-12-07T22:56:27.257056Z[0m [32m INFO[0m [2mgossip-lib/src/filter.rs[0m[2m:[0m[2m43:[0m Spam filter loaded.
|
||||||
|
[2m2023-12-07T22:56:27.288275Z[0m [32m INFO[0m [2m/home/mike/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/linux/x11/window.rs[0m[2m:[0m[2m156:[0m Guessed window scale factor: 1.0416666666666667
|
||||||
|
[2m2023-12-07T22:56:27.405842Z[0m [32m INFO[0m [2mgossip-bin/src/ui/mod.rs[0m[2m:[0m[2m478:[0m DPI (native): 75
|
||||||
|
[2m2023-12-07T22:56:33.171088Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/mod.rs[0m[2m:[0m[2m282:[0m Picked wss://nostr-pub.wellorder.net/ covering 151 pubkeys
|
||||||
|
[2m2023-12-07T22:56:33.171554Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/mod.rs[0m[2m:[0m[2m282:[0m Picked wss://nos.lol/ covering 152 pubkeys
|
||||||
|
[2m2023-12-07T22:56:33.171745Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/mod.rs[0m[2m:[0m[2m282:[0m Picked wss://eden.nostr.land/ covering 1 pubkeys
|
||||||
|
[2m2023-12-07T22:56:33.171772Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/mod.rs[0m[2m:[0m[2m277:[0m Done picking relays: All people accounted for.
|
||||||
|
[2m2023-12-07T22:56:33.399922Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m133:[0m wss://nostr.mikedilger.com/: Relay Information: Name="nostr-rs-relay" Description="Mike Dilger's archive relay, not for general use." Pubkey="ee11a5dff40c19a555f41fe42b48f00e618c91225622ae37b6c2bb67b76c4e49" Contact="mailto:mike@mikedilger.com" NIPS=[1, 2, 9, 11, 12, 15, 16, 20, 22, 33, 40, 42] Software="https://git.sr.ht/~gheartsfield/nostr-rs-relay" Version="0.8.9" Limitation="Relay Limitation: PaymentRequired="false"" id=""wss://nostr.mikedilger.com""
|
||||||
|
[2m2023-12-07T22:56:33.523633Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m228:[0m wss://nostr.mikedilger.com/: Connected
|
||||||
|
[2m2023-12-07T22:56:33.525790Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m909:[0m NEW SUBSCRIPTION on wss://nostr.mikedilger.com/ handle=config_feed, id=0
|
||||||
|
[2m2023-12-07T22:56:33.602171Z[0m [34mDEBUG[0m [2mgossip-lib/src/process.rs[0m[2m:[0m[2m164:[0m wss://nostr.mikedilger.com/: New Event: config_feed ContactList @1699940805
|
||||||
|
[2m2023-12-07T22:56:34.067527Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m133:[0m wss://nostr.wine/: Relay Information: Name="nostr.wine" Description="A paid nostr relay for wine enthusiasts and everyone else." Pubkey="4918eb332a41b71ba9a74b1dc64276cfff592e55107b93baae38af3520e55975" Contact="wino@nostr.wine" NIPS=[1, 2, 4, 9, 11, 12, 15, 16, 20, 22, 28, 33, 40, 42] Software="https://nostr.wine" Version="0.3.1" Limitation="Relay Limitation: MaxMessageLength="131072" MaxSubscriptions="50" MaxLimit="1000" MaxSubidLength="71" MaxEventTags="2000" MinPowDifficulty="0" AuthRequired="false" PaymentRequired="true"" PaymentsUrl=https://nostr.wine/invoices Fees=Relay Fees: Admission=[Fee=[18888000 msats Kinds="[]"] ],Subscription=[],Publication=[] icon=""https://image.nostr.build/dda8ffb9d8d87d34c7d0b0b9cf54a0466bfab69939b0c9a2bd430bac1540cadf.jpg""
|
||||||
|
[2m2023-12-07T22:56:34.077020Z[0m [34mDEBUG[0m [2mgossip-lib/src/process.rs[0m[2m:[0m[2m164:[0m wss://nostr.mikedilger.com/: New Event: config_feed Metadata @1700863736
|
||||||
|
[2m2023-12-07T22:56:34.091929Z[0m [34mDEBUG[0m [2mgossip-lib/src/process.rs[0m[2m:[0m[2m164:[0m wss://nostr.mikedilger.com/: New Event: config_feed FollowSets @1701213881
|
||||||
|
[2m2023-12-07T22:56:34.443721Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m133:[0m wss://offchain.pub/: Relay Information: Name="offchain.pub" Description="public nostr relay running strfry" Pubkey="6b1b35c6dee48851bac53a4494ca8f819503be00212dbceb899dc03acd7641db" Contact="admin@offchain.pub" NIPS=[1, 2, 4, 9, 11, 12, 16, 20, 22, 28, 33, 40] Software="git+https://github.com/hoytech/strfry.git" Version="0.9.6"
|
||||||
|
[2m2023-12-07T22:56:34.511799Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m133:[0m wss://nos.lol/: Relay Information: Name="nos.lol" Description="Generally accepts notes, except spammy ones." Contact="unset" NIPS=[1, 2, 4, 9, 11, 12, 16, 20, 22, 28, 33, 40] Software="git+https://github.com/hoytech/strfry.git" Version="0.9.6"
|
||||||
|
[2m2023-12-07T22:56:34.667891Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m133:[0m wss://purplepag.es/: Relay Information: Name="purplepag.es" Description="Nostr's Purple Pages" Pubkey="fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52" Contact="pablof7z.com" NIPS=[1, 2, 4, 9, 11, 12, 16, 20, 22, 28, 33, 40] Software="git+https://github.com/hoytech/strfry.git" Version="0.9.6-7-g7196547"
|
||||||
|
[2m2023-12-07T22:56:34.691831Z[0m [34mDEBUG[0m [2mgossip-lib/src/overlord/minion/mod.rs[0m[2m:[0m[2m228:[0m wss://nostr.wine/: Connected
|
||||||
|
DEBUG: SAVING SETTINGS seeking a write txn...
|
Loading…
Reference in New Issue
Block a user