Enable offline posting
You can now post, like, repost, reply offline Changelog-Added: Enable offline posting
This commit is contained in:
@@ -7,13 +7,22 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct CommandResult {
|
||||
let event_id: String
|
||||
let ok: Bool
|
||||
let msg: String
|
||||
}
|
||||
|
||||
enum NostrResponse: Decodable {
|
||||
case event(String, NostrEvent)
|
||||
case notice(String)
|
||||
case eose(String)
|
||||
case ok(CommandResult)
|
||||
|
||||
var subid: String? {
|
||||
switch self {
|
||||
case .ok(_):
|
||||
return nil
|
||||
case .event(let sub_id, _):
|
||||
return sub_id
|
||||
case .eose(let sub_id):
|
||||
@@ -48,6 +57,19 @@ enum NostrResponse: Decodable {
|
||||
let sub_id = try container.decode(String.self)
|
||||
self = .eose(sub_id)
|
||||
return
|
||||
} else if typ == "OK" {
|
||||
var cr: CommandResult
|
||||
do {
|
||||
let event_id = try container.decode(String.self)
|
||||
let ok = try container.decode(Bool.self)
|
||||
let msg = try container.decode(String.self)
|
||||
cr = CommandResult(event_id: event_id, ok: ok, msg: msg)
|
||||
} catch {
|
||||
print(error)
|
||||
throw error
|
||||
}
|
||||
self = .ok(cr)
|
||||
//ev.pow = count_hash_leading_zero_bits(ev.id)
|
||||
}
|
||||
|
||||
throw DecodingError.dataCorrupted(.init(codingPath: [], debugDescription: "expected EVENT or NOTICE, got \(typ)"))
|
||||
|
||||
@@ -256,7 +256,6 @@ class RelayPool {
|
||||
}
|
||||
}
|
||||
|
||||
// handle reconnect logic, etc?
|
||||
for handler in handlers {
|
||||
handler.callback(relay_id, event)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user