ui: Filter out reposts where the inner event is from a person whom the user has muted. (#1216)

Issue reproduction
------------------

**Device:** iPhone 14 Pro simulator
**iOS:** 17.0
**Damus:** `bb2eb904cc`
**Steps:**

1. Repost a note from another account (Account "B")
2. Mute user "B"
3. Check home page and your own profile page. Repost shows up with a muted box.

Fix

Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Daniel D’Aquino
2023-09-30 03:17:16 +00:00
committed by William Casarin
parent 0f86a41c4a
commit 66d731ad0a
4 changed files with 22 additions and 7 deletions

View File

@@ -25,7 +25,15 @@ enum FilterState : Int {
/// Simple filter to determine whether to show posts with #nsfw tags
func nsfw_tag_filter(ev: NostrEvent) -> Bool {
return ev.referenced_hashtags.first(where: { t in t.hashtag == "nsfw" }) == nil
return ev.referenced_hashtags.first(where: { t in t.hashtag == "nsfw" }) == nil
}
func get_repost_of_muted_user_filter(damus_state: DamusState) -> ((_ ev: NostrEvent) -> Bool) {
return { ev in
guard ev.known_kind == .boost else { return true }
guard let inner_ev = ev.get_inner_event(cache: damus_state.events) else { return true }
return should_show_event(keypair: damus_state.keypair, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: inner_ev)
}
}
/// Generic filter with various tweakable settings
@@ -44,11 +52,12 @@ struct ContentFilters {
}
extension ContentFilters {
static func defaults(_ settings: UserSettingsStore) -> [(NostrEvent) -> Bool] {
static func defaults(damus_state: DamusState) -> [(NostrEvent) -> Bool] {
var filters = Array<(NostrEvent) -> Bool>()
if settings.hide_nsfw_tagged_content {
if damus_state.settings.hide_nsfw_tagged_content {
filters.append(nsfw_tag_filter)
}
filters.append(get_repost_of_muted_user_filter(damus_state: damus_state))
return filters
}
}