Update 56.md

Co-authored-by: Leo Wandersleb <leo@leowandersleb.de>
This commit is contained in:
William Casarin 2023-01-31 06:42:11 -08:00 committed by GitHub
parent b3736f6204
commit 5c9bf68d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

44
56.md
View File

@ -30,27 +30,37 @@ A `report` tag MUST be included which consists of the following report types:
Some report tags only make sense for profile reports, such as `impersonation`
Example code
Example events
--------------
```swift
enum ReportType: String {
case explicit
case illegal
case spam
case impersonation
```json
{
"kind": 1984,
"tags": [
[ "p", <pubkey>, "explicit"]
],
"content": "",
...
}
func create_report_tags(target: ReportTarget, type: ReportType) -> [[String]] {
var tags: [[String]]
switch target {
case .user(let pubkey):
tags = [["p", pubkey]]
case .note(let notet):
tags = [["e", notet.note_id], ["p", notet.pubkey]]
}
{
"kind": 1984,
"tags": [
[ "e", <eventId>, "illegal"],
[ "p", <pubkey>]
],
"content": "He's insulting the king!",
...
}
tags.append(["report", type.rawValue])
return tags
{
"kind": 1984,
"tags": [
[ "p", <impersonator pubkey>, "impersonation"],
[ "p", <victim pubkey>]
],
"content": "Profile is imitating #[1]",
...
}
```