refactor: event is_ephemeral method

This commit is contained in:
Greg Heartsfield 2023-01-24 08:04:42 -06:00
parent 25752abe6b
commit 5c07b2eca5
2 changed files with 7 additions and 2 deletions

View File

@ -212,9 +212,9 @@ pub async fn db_writer(
}
// TODO: cache recent list of authors to remove a DB call.
let start = Instant::now();
if event.kind >= 20000 && event.kind < 30000 {
if event.is_ephemeral() {
bcast_tx.send(event.clone()).ok();
info!(
debug!(
"published ephemeral event: {:?} from: {:?} in: {:?}",
event.get_event_id_prefix(),
event.get_author_prefix(),

View File

@ -120,6 +120,11 @@ impl Event {
self.kind == 0
}
/// Should this event be persisted?
#[must_use] pub fn is_ephemeral(&self) -> bool {
self.kind >= 20000 && self.kind < 30000
}
/// Should this event be replaced with newer timestamps from same author?
#[must_use] pub fn is_replaceable(&self) -> bool {
self.kind == 0 || self.kind == 3 || self.kind == 41 || (self.kind >= 10000 && self.kind < 20000)