mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 11:43:43 +00:00
Pass subscription (handle) to process_new_events
This commit is contained in:
parent
9fd668bb82
commit
dbba43c87d
@ -35,7 +35,8 @@ pub struct Globals {
|
|||||||
pub events: RwLock<HashMap<Id, Event>>,
|
pub events: RwLock<HashMap<Id, Event>>,
|
||||||
|
|
||||||
/// Events coming in from relays that are not processed yet
|
/// Events coming in from relays that are not processed yet
|
||||||
pub incoming_events: RwLock<Vec<(Event, Url)>>,
|
/// stored with Url they came from and Subscription they came in on
|
||||||
|
pub incoming_events: RwLock<Vec<(Event, Url, Option<String>)>>,
|
||||||
|
|
||||||
/// All relationships between events
|
/// All relationships between events
|
||||||
pub relationships: RwLock<HashMap<Id, Vec<(Id, Relationship)>>>,
|
pub relationships: RwLock<HashMap<Id, Vec<(Id, Relationship)>>>,
|
||||||
@ -165,7 +166,7 @@ impl Globals {
|
|||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for event in events.iter() {
|
for event in events.iter() {
|
||||||
count += 1;
|
count += 1;
|
||||||
crate::process::process_new_event(event, false, None).await?;
|
crate::process::process_new_event(event, false, None, None).await?;
|
||||||
}
|
}
|
||||||
tracing::info!("Loaded {} desired events from the database", count);
|
tracing::info!("Loaded {} desired events from the database", count);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,13 @@ impl Minion {
|
|||||||
tracing::debug!("{}: {}: NEW EVENT", &self.url, handle);
|
tracing::debug!("{}: {}: NEW EVENT", &self.url, handle);
|
||||||
|
|
||||||
// Try processing everything immediately
|
// Try processing everything immediately
|
||||||
crate::process::process_new_event(&event, true, Some(self.url.clone())).await?;
|
crate::process::process_new_event(
|
||||||
|
&event,
|
||||||
|
true,
|
||||||
|
Some(self.url.clone()),
|
||||||
|
Some(handle),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if event.kind == EventKind::TextNote {
|
if event.kind == EventKind::TextNote {
|
||||||
@ -40,7 +46,7 @@ impl Minion {
|
|||||||
.incoming_events
|
.incoming_events
|
||||||
.write()
|
.write()
|
||||||
.await
|
.await
|
||||||
.push((*event, self.url.clone()));
|
.push((*event, self.url.clone(), handle));
|
||||||
} else {
|
} else {
|
||||||
// Process everything else immediately
|
// Process everything else immediately
|
||||||
crate::process::process_new_event(&event, true, Some(self.url.clone()))
|
crate::process::process_new_event(&event, true, Some(self.url.clone()))
|
||||||
|
@ -121,7 +121,7 @@ impl Overlord {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Process this metadata event to update people
|
// Process this metadata event to update people
|
||||||
crate::process::process_new_event(&e, false, None).await?;
|
crate::process::process_new_event(&e, false, None, None).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ impl Overlord {
|
|||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for event in events.iter() {
|
for event in events.iter() {
|
||||||
count += 1;
|
count += 1;
|
||||||
crate::process::process_new_event(event, false, None).await?;
|
crate::process::process_new_event(event, false, None, None).await?;
|
||||||
}
|
}
|
||||||
tracing::info!("Loaded {} events from the database", count);
|
tracing::info!("Loaded {} events from the database", count);
|
||||||
}
|
}
|
||||||
@ -492,9 +492,9 @@ impl Overlord {
|
|||||||
GLOBALS.event_is_new.write().await.clear();
|
GLOBALS.event_is_new.write().await.clear();
|
||||||
|
|
||||||
let _ = tokio::spawn(async move {
|
let _ = tokio::spawn(async move {
|
||||||
for (event, url) in GLOBALS.incoming_events.write().await.drain(..) {
|
for (event, url, sub) in GLOBALS.incoming_events.write().await.drain(..) {
|
||||||
let _ =
|
let _ = crate::process::process_new_event(&event, true, Some(url), sub)
|
||||||
crate::process::process_new_event(&event, true, Some(url)).await;
|
.await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -774,7 +774,7 @@ impl Overlord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process the message for ourself
|
// Process the message for ourself
|
||||||
crate::process::process_new_event(&event, false, None).await?;
|
crate::process::process_new_event(&event, false, None, None).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -832,7 +832,7 @@ impl Overlord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process the message for ourself
|
// Process the message for ourself
|
||||||
crate::process::process_new_event(&event, false, None).await?;
|
crate::process::process_new_event(&event, false, None, None).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -897,7 +897,7 @@ impl Overlord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process the message for ourself
|
// Process the message for ourself
|
||||||
crate::process::process_new_event(&event, false, None).await?;
|
crate::process::process_new_event(&event, false, None, None).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ pub async fn process_new_event(
|
|||||||
event: &Event,
|
event: &Event,
|
||||||
from_relay: bool,
|
from_relay: bool,
|
||||||
seen_on: Option<Url>,
|
seen_on: Option<Url>,
|
||||||
|
_subscription: Option<String>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// Save the event into the database
|
// Save the event into the database
|
||||||
if from_relay {
|
if from_relay {
|
||||||
|
Loading…
Reference in New Issue
Block a user