Censor unclebobmartin from damus
Limits the size of posts viewable within damus to 32,000 bytes. It's still probably too big, but let's have some sane limit so uncle's named bob can't break your app just because they can. Changelog-Fixed: Limit post sizes to max 32,000 as an upper bound sanity limit. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -338,7 +338,7 @@ class HomeModel: ObservableObject {
|
||||
}
|
||||
|
||||
func should_hide_event(_ ev: NostrEvent) -> Bool {
|
||||
return false
|
||||
return !ev.should_show_event
|
||||
}
|
||||
|
||||
func handle_text_event(sub_id: String, _ ev: NostrEvent) {
|
||||
|
||||
@@ -68,6 +68,10 @@ class ProfileModel: ObservableObject {
|
||||
}
|
||||
|
||||
func add_event(_ ev: NostrEvent) {
|
||||
guard ev.should_show_event else {
|
||||
return
|
||||
}
|
||||
|
||||
if seen_event.contains(ev.id) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class SearchHomeModel: ObservableObject {
|
||||
guard sub_id == self.base_subid || sub_id == self.profiles_subid else {
|
||||
return
|
||||
}
|
||||
if ev.kind == NostrKind.text.rawValue {
|
||||
if ev.is_textlike && ev.should_show_event {
|
||||
if seen_pubkey.contains(ev.pubkey) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class SearchModel: ObservableObject {
|
||||
|
||||
func handle_event(relay_id: String, ev: NostrConnectionEvent) {
|
||||
let done = handle_subid_event(pool: pool, sub_id: sub_id, relay_id: relay_id, ev: ev) { ev in
|
||||
if ev.known_kind == .text {
|
||||
if ev.known_kind == .text && ev.should_show_event {
|
||||
self.add_event(ev)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,10 @@ class ThreadModel: ObservableObject {
|
||||
}
|
||||
|
||||
func add_event(_ ev: NostrEvent, privkey: String?) {
|
||||
guard ev.should_show_event else {
|
||||
return
|
||||
}
|
||||
|
||||
if event_map[ev.id] != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,6 +55,18 @@ class NostrEvent: Codable, Identifiable, CustomStringConvertible {
|
||||
let created_at: Int64
|
||||
let kind: Int
|
||||
let content: String
|
||||
|
||||
var is_textlike: Bool {
|
||||
return kind == 1 || kind == 42
|
||||
}
|
||||
|
||||
var too_big: Bool {
|
||||
return self.content.count > 32000
|
||||
}
|
||||
|
||||
var should_show_event: Bool {
|
||||
return !too_big
|
||||
}
|
||||
|
||||
private var _blocks: [Block]? = nil
|
||||
func blocks(_ privkey: String?) -> [Block] {
|
||||
|
||||
Reference in New Issue
Block a user