Implement apply_spam_filter_on_incoming_events

This commit is contained in:
Mike Dilger 2024-09-11 10:57:46 +12:00
parent 354f0bcf22
commit ca41373ac5

View File

@ -5,7 +5,6 @@ use crate::globals::GLOBALS;
use crate::misc::{Freshness, Private};
use crate::people::{People, PersonList, PersonListMetadata};
use crate::relationship::{RelationshipByAddr, RelationshipById};
use crate::spam_filter::EventFilterAction;
use crate::storage::{PersonTable, Table};
use heed::RwTxn;
use nostr_types::{
@ -76,6 +75,12 @@ pub fn process_new_event(
)?;
}
if GLOBALS
.db()
.read_setting_apply_spam_filter_on_incoming_events()
{
use crate::spam_filter::EventFilterAction;
// Spam filter (displayable and author is not followed)
if (event.kind.is_feed_displayable() || event.kind == EventKind::GiftWrap)
&& !GLOBALS
@ -106,6 +111,7 @@ pub fn process_new_event(
}
}
}
}
// Invalidate the note itself (due to seen_on probably changing)
GLOBALS.ui_notes_to_invalidate.write().push(event.id);