Simplify and inline Report event logic.
Closes: https://github.com/damus-io/damus/pull/1498 Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
8b600a9774
commit
c5d8e4a4a1
@@ -38,31 +38,5 @@ struct ReportNoteTarget {
|
||||
enum ReportTarget {
|
||||
case user(Pubkey)
|
||||
case note(ReportNoteTarget)
|
||||
|
||||
static func note(pubkey: Pubkey, note_id: NoteId) -> ReportTarget {
|
||||
return .note(ReportNoteTarget(pubkey: pubkey, note_id: note_id))
|
||||
}
|
||||
}
|
||||
|
||||
struct Report {
|
||||
let type: ReportType
|
||||
let target: ReportTarget
|
||||
let message: String
|
||||
|
||||
}
|
||||
|
||||
func create_report_tags(target: ReportTarget, type: ReportType) -> [[String]] {
|
||||
switch target {
|
||||
case .user(let pubkey):
|
||||
return [["p", pubkey.hex(), type.rawValue]]
|
||||
case .note(let notet):
|
||||
return [["e", notet.note_id.hex(), type.rawValue],
|
||||
["p", notet.pubkey.hex()]]
|
||||
}
|
||||
}
|
||||
|
||||
func create_report_event(keypair: FullKeypair, report: Report) -> NostrEvent? {
|
||||
let kind: UInt32 = 1984
|
||||
let tags = create_report_tags(target: report.target, type: report.type)
|
||||
return NostrEvent(content: report.message, keypair: keypair.to_keypair(), kind: kind, tags: tags)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user