Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIP 56 mapping changes #1289

Merged
merged 11 commits into from
Jul 16, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Add impersonation flag category and better NIP-56 mapping.
- Added a filter button to the Home tab that lets you browse all notes on a specific relay.
- Add a Tap to Refresh button in empty profiles.
- Update the reply count shown below each Note in a Feed.
Expand Down
16 changes: 12 additions & 4 deletions Nos/Models/ReportCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ReportCategory: Identifiable, Equatable {
}

enum NIP56Code: String {
case nudity, profanity, illegal, spam, impersonation, other
case nudity, malware, profanity, illegal, spam, impersonation, other
}

enum ReportCategoryType {
Expand All @@ -61,7 +61,7 @@ enum ReportCategoryType {
static let harassment = ReportCategory(
name: .moderation.harassment,
code: "IL-har",
nip56Code: .other
nip56Code: .profanity
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep this one as other also. harassment != profanity and in my opinion it's better to be vague and say "other" than to be wrong. We've seen people get upset when they feel like their content has been labeled wrongly and this will only increase that.

)

static let intoleranceAndHate = ReportCategory(
Expand Down Expand Up @@ -89,7 +89,13 @@ enum ReportCategoryType {
static let nsfw = ReportCategory(
name: .moderation.nsfw,
code: "NW",
nip56Code: .other
nip56Code: .nudity
Copy link
Contributor

Choose a reason for hiding this comment

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

While NSFW content may contain nudity, it's not the only option. According to Wikipedia:

The marked content may contain graphic violence, pornography, profanity, nudity, slurs or other potentially disturbing subject matter.

I don't know how NIP-56 is typically used, so maybe .nudity is better than .other for NSFW, but I want to be sure we use the best option here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@setch-l what about changing the NSFW acronym to something else?

Copy link

Choose a reason for hiding this comment

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

Nudity and sexual content is fine.

We don't have anything for violence so then it simply results in expanding the categories once again. The goal of this work was in the moment to not have to make people think. More than 7 categories requires people to think too much.

Copy link
Member

Choose a reason for hiding this comment

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

🤔 why are we bending ourselves around what is in NIP-56? We know it doesn't work for us, that's why we have made our own categories. So let's keep NSFW as a category, it's very broadly useful, and continue mapping it to other for clients that only support NIP-56?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use other we need to get back to use NIP-69 to get the specifics in addition to NIP-56 as we were doing before these changes. If we do that, then the buttons in the Slack channel should be NIP-69 categories, not NIP-56. Not all of what NIP-69 offers but only the same subset available through the app.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I've read the ticket comments now. I didn't realize we were completely overhauling the categories. This PR is still publishing events with NIP-69 labels, right? Are you planning to remove those in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not anymore, this was covered in cd865bf

)

static let impersonation = ReportCategory(
name: .moderation.impersonation,
code: "IM",
nip56Code: .impersonation
)

static let nudity = ReportCategory(
Expand Down Expand Up @@ -138,6 +144,7 @@ extension ReportCategoryType {
ReportCategoryType.likelyToCauseHarm,
ReportCategoryType.harassment,
ReportCategoryType.intoleranceAndHate,
ReportCategoryType.impersonation,
ReportCategoryType.illegal,
ReportCategoryType.nsfw,
ReportCategoryType.nudity,
Expand All @@ -150,8 +157,9 @@ extension ReportCategoryType {
static let authorCategories = [
ReportCategoryType.spam,
ReportCategoryType.harassment,
ReportCategoryType.nsfw,
ReportCategoryType.nudity,
ReportCategoryType.illegal,
ReportCategoryType.impersonation,
ReportCategoryType.other,
]

Expand Down
5 changes: 1 addition & 4 deletions Nos/Service/ReportPublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ class ReportPublisher {
var event = JSONEvent(
pubKey: pubKey,
kind: .report,
tags: [
["L", "MOD"],
["l", "MOD>\(category.code)", "MOD"]
],
tags: [],
content: String(localized: .localizable.reportEventContent(category.displayName))
)

Expand Down
6 changes: 2 additions & 4 deletions Nos/Views/PreviewData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,8 @@ struct PreviewData {
note.kind = EventKind.report.rawValue
note.content = "this person is spammy"
note.allTags = [
[ "p", "6b165e83a3b7d333a6e7db1f200dc627e31eb5170285c29ded271be203c5da37", "other" ],
[ "e", "ad0cea87d9c81e3bc5b15ddf561b1a2bbbff3d8318d4ea9ccd4644def9e035b8", "other" ],
[ "L", "MOD" ],
[ "l", "MOD>SP", "MOD", "{\"confidence\":0.9876784682273865}" ]
[ "p", "6b165e83a3b7d333a6e7db1f200dc627e31eb5170285c29ded271be203c5da37", "spam" ],
[ "e", "ad0cea87d9c81e3bc5b15ddf561b1a2bbbff3d8318d4ea9ccd4644def9e035b8", "spam" ],
] as NSObject
note.author = alice
note.createdAt = .now
Expand Down
6 changes: 1 addition & 5 deletions NosTests/Model/ReportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ final class ReportTests: XCTestCase {
func testFindCategory() throws {
XCTAssertEqual(
ReportCategory.findCategory(from: "PN"),
ReportCategoryType.allCategories[7]
)
XCTAssertEqual(
ReportCategory.findCategory(from: "VI-hum"),
ReportCategoryType.allCategories[9].subCategories![0]
ReportCategoryType.allCategories[8]
)
}
}
2 changes: 0 additions & 2 deletions NosTests/Service/ReportPublisherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ final class ReportPublisherTests: CoreDataTestCase {
XCTAssertEqual(publicReport.kind, EventKind.report.rawValue)
XCTAssertEqual(publicReport.pubKey, aliceKeyPair.publicKeyHex)
XCTAssertEqual(publicReport.tags, [
["L", "MOD"],
["l", "MOD>CL", "MOD"],
["e", note.identifier!, "profanity"],
["p", bobKeyPair.publicKeyHex]
])
Expand Down
Loading