commit d69d3cc74e415a73b2e3f913997b70e9149ba0d7
parent 6e220ac4c1dac3e8d807a9331884647d9d959a7b
Author: William Casarin <jb55@jb55.com>
Date: Sat, 14 Jan 2023 16:28:18 -0800
create_dm: allow created_at argument
This is mainly used by tests
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/damus/Views/DMChatView.swift b/damus/Views/DMChatView.swift
@@ -166,7 +166,7 @@ struct DMChatView_Previews: PreviewProvider {
}
-func create_dm(_ message: String, to_pk: String, tags: [[String]], keypair: Keypair) -> NostrEvent?
+func create_dm(_ message: String, to_pk: String, tags: [[String]], keypair: Keypair, created_at: Int64? = nil) -> NostrEvent?
{
guard let privkey = keypair.privkey else {
return nil
@@ -181,7 +181,9 @@ func create_dm(_ message: String, to_pk: String, tags: [[String]], keypair: Keyp
return nil
}
let enc_content = encode_dm_base64(content: enc_message.bytes, iv: iv)
- let ev = NostrEvent(content: enc_content, pubkey: keypair.pubkey, kind: 4, tags: tags)
+ let created = created_at ?? Int64(Date().timeIntervalSince1970)
+ let ev = NostrEvent(content: enc_content, pubkey: keypair.pubkey, kind: 4, tags: tags, createdAt: created)
+
ev.calculate_id()
ev.sign(privkey: privkey)
return ev