Fix event encoding issue
This commit is contained in:
@@ -370,6 +370,7 @@ func decode_nostr_event(txt: String) -> NostrResponse? {
|
|||||||
|
|
||||||
func encode_json<T: Encodable>(_ val: T) -> String? {
|
func encode_json<T: Encodable>(_ val: T) -> String? {
|
||||||
let encoder = JSONEncoder()
|
let encoder = JSONEncoder()
|
||||||
|
encoder.outputFormatting = .withoutEscapingSlashes
|
||||||
return (try? encoder.encode(val)).map { String(decoding: $0, as: UTF8.self) }
|
return (try? encoder.encode(val)).map { String(decoding: $0, as: UTF8.self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,10 +118,9 @@ func make_nostr_req(_ req: NostrRequest) -> String? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func make_nostr_push_event(ev: NostrEvent) -> String? {
|
func make_nostr_push_event(ev: NostrEvent) -> String? {
|
||||||
let encoder = JSONEncoder()
|
guard let event = encode_json(ev) else {
|
||||||
encoder.outputFormatting = .withoutEscapingSlashes
|
return nil
|
||||||
let event_data = try! encoder.encode(ev)
|
}
|
||||||
let event = String(decoding: event_data, as: UTF8.self)
|
|
||||||
let encoded = "[\"EVENT\",\(event)]"
|
let encoded = "[\"EVENT\",\(event)]"
|
||||||
print(encoded)
|
print(encoded)
|
||||||
return encoded
|
return encoded
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ func fetch_zap_invoice(_ payreq: LNUrlPayRequest, zapreq: NostrEvent, amount: In
|
|||||||
|
|
||||||
if zappable {
|
if zappable {
|
||||||
if let json = encode_json(zapreq) {
|
if let json = encode_json(zapreq) {
|
||||||
|
print("zapreq json: \(json)")
|
||||||
query.append(URLQueryItem(name: "nostr", value: json))
|
query.append(URLQueryItem(name: "nostr", value: json))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user