Skip to content

Commit

Permalink
Merge pull request #1289 from planetary-social/nip56-mapping
Browse files Browse the repository at this point in the history
NIP 56 mapping changes
  • Loading branch information
dcadenas authored Jul 16, 2024
2 parents 7a0d006 + cbcc7c8 commit 7e6b2b0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
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
)

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
)

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

0 comments on commit 7e6b2b0

Please sign in to comment.