Skip to content

Commit

Permalink
More work on inbox feed
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Jun 10, 2024
1 parent da818ab commit e7db13e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
34 changes: 16 additions & 18 deletions gossip-lib/src/feed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl Feed {

let filter = {
let mut filter = Filter::new();
filter.kinds = feed_displayable_event_kinds(true);
filter.kinds = feed_displayable_event_kinds(false);
filter.add_tag_value('p', my_pubkey.as_hex_string());
filter
};
Expand All @@ -296,23 +296,21 @@ impl Feed {

let screen = |e: &Event| {
e.pubkey != my_pubkey
&& ((e.kind == EventKind::GiftWrap
|| e.kind == EventKind::EncryptedDirectMessage)
|| (
// We can't check against EventReference::Id because we would
// have to know all the Ids of my events, which is too much to
// check against. BUT we can check for these cheaply:
matches!(
e.replies_to(),
Some(EventReference::Addr(EventAddr { author, .. }))
if author == my_pubkey
) || (
indirect
|| e.people_referenced_in_content()
.iter()
.any(|p| *p == my_pubkey)
)
))
&& (
// We can't check against EventReference::Id because we would
// have to know all the Ids of my events, which is too much to
// check against. BUT we can check for these cheaply:
matches!(
e.replies_to(),
Some(EventReference::Addr(EventAddr { author, .. }))
if author == my_pubkey
) || (
indirect
|| e.people_referenced_in_content()
.iter()
.any(|p| *p == my_pubkey)
)
)
};

let events = Self::load_event_range(anchor, filter, true, false, screen).await?;
Expand Down
4 changes: 2 additions & 2 deletions gossip-lib/src/overlord/minion/filter_fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ pub fn general_feed(authors: &[PublicKey], range: FeedRange) -> Vec<Filter> {
pub fn inbox_feed(spamsafe: bool, range: FeedRange) -> Vec<Filter> {
let mut filters: Vec<Filter> = Vec::new();

// Allow all feed related event kinds (including DMs)
let mut event_kinds = crate::feed::feed_related_event_kinds(true);
// Allow all feed displayable event kinds (including DMs)
let mut event_kinds = crate::feed::feed_displayable_event_kinds(true);
event_kinds.retain(|f| *f != EventKind::GiftWrap); // gift wrap has special filter

let (since, until, limit) = range.since_until_limit();
Expand Down

0 comments on commit e7db13e

Please sign in to comment.