Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion damus/Models/ContentFilters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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 && References<ContentWarningTag>(tags: ev.tags).first == nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont we need to check the reason == nsfw in the content warning case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider any post with the "content-warning" tag as sensitive.
Therefore, there is no need to check the "reason."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a post without reason.
https://nostter.app/nevent1qqswynxvz0wth52wjq3xyq7l795q3w0fe83ym0ewetnx8u9gslrhmhswwl5pw

{
  "content": "",
  "created_at": 1718237816,
  "id": "e24ccc13dcbbd14e90226203dff16808b9e9c9e24dbf2ecae663f0a887c77dde",
  "kind": 1,
  "pubkey": "1a35b54ef7752af54cacbeedf0f349e320f0a2ee50142883134c3ee31879ce71",
  "sig": "3a1dc4873e2a8527ecfce2526af8701702e0d1bb3b4c4ecf45e8026cae27ceb84f40144e8409ca4a325e8e93f39fcba75ddf1c7ad0e57ba53f7e538a4da92b2a",
  "tags": [
    [
      "content-warning"
    ]
  ]
}

}

func get_repost_of_muted_user_filter(damus_state: DamusState) -> ((_ ev: NostrEvent) -> Bool) {
Expand Down
23 changes: 23 additions & 0 deletions damus/Nostr/Id.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,29 @@ struct ReplaceableParam: TagConvertible {
var keychar: AsciiCharacter { "d" }
}

struct ContentWarningTag: TagConvertible {
let reason: String?

static func from_tag(tag: TagSequence) -> ContentWarningTag? {
var i = tag.makeIterator()

guard tag.count >= 1,
let t0 = i.next(),
t0.matches_str("content-warning") else {
return nil
}

guard let t1 = i.next() else {
return ContentWarningTag(reason: nil)
}

return ContentWarningTag(reason: t1.string())
}
var tag: [String] {
self.reason == nil ? ["content-warning"] : ["content-warning", self.reason!]
}
}

struct Signature: Hashable, Equatable {
let data: Data

Expand Down