mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-20 03:57:03 +00:00
Command to post nip46 server results
This commit is contained in:
parent
43cf37b6f2
commit
8eda848746
@ -101,6 +101,9 @@ pub enum ToOverlordMessage {
|
||||
dm_channel: Option<DmChannel>,
|
||||
},
|
||||
|
||||
/// Calls [post_nip46_event](crate::Overlord::post_nip46_event)
|
||||
PostNip46Event(Event, Vec<RelayUrl>),
|
||||
|
||||
/// Calls [prune_cache](crate::Overlord::prune_cache)
|
||||
PruneCache,
|
||||
|
||||
@ -255,6 +258,7 @@ pub enum RelayConnectionReason {
|
||||
PostLike,
|
||||
PostMetadata,
|
||||
PostMuteList,
|
||||
PostNostrConnect,
|
||||
ReadThread,
|
||||
SubscribePerson,
|
||||
}
|
||||
@ -285,6 +289,7 @@ impl RelayConnectionReason {
|
||||
PostContacts => "Posting our contact list",
|
||||
PostMuteList => "Posting our mute list",
|
||||
PostMetadata => "Posting our metadata",
|
||||
PostNostrConnect => "Posting nostrconnect",
|
||||
ReadThread => "Reading ancestors to build a thread",
|
||||
SubscribePerson => "Subscribe to the events of a person",
|
||||
}
|
||||
@ -308,6 +313,7 @@ impl RelayConnectionReason {
|
||||
PostContacts => false,
|
||||
PostMuteList => false,
|
||||
PostMetadata => false,
|
||||
PostNostrConnect => false,
|
||||
ReadThread => true,
|
||||
SubscribePerson => false,
|
||||
}
|
||||
|
@ -622,6 +622,9 @@ impl Overlord {
|
||||
} => {
|
||||
self.post(content, tags, in_reply_to, dm_channel).await?;
|
||||
}
|
||||
ToOverlordMessage::PostNip46Event(event, relays) => {
|
||||
self.post_nip46_event(event, relays).await?;
|
||||
}
|
||||
ToOverlordMessage::PruneCache => {
|
||||
Self::prune_cache().await?;
|
||||
}
|
||||
@ -1873,6 +1876,31 @@ impl Overlord {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn post_nip46_event(
|
||||
&mut self,
|
||||
event: Event,
|
||||
relays: Vec<RelayUrl>,
|
||||
) -> Result<(), Error> {
|
||||
for url in relays {
|
||||
// Send it the event to post
|
||||
tracing::debug!("Asking {} to post nostrconnect", &url);
|
||||
|
||||
self.engage_minion(
|
||||
url.clone(),
|
||||
vec![RelayJob {
|
||||
reason: RelayConnectionReason::PostNostrConnect,
|
||||
payload: ToMinionPayload {
|
||||
job_id: rand::random::<u64>(),
|
||||
detail: ToMinionPayloadDetail::PostEvent(Box::new(event.clone())),
|
||||
},
|
||||
}],
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Prune the cache (downloaded files)
|
||||
pub async fn prune_cache() -> Result<(), Error> {
|
||||
GLOBALS
|
||||
|
Loading…
Reference in New Issue
Block a user