damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | LICENSE

commit cdbcf0f6e0c2ef29944faab7c794e39ae969dbfb
parent f38b1be9e09731e57fe945f8c88e509073fee02b
Author: William Casarin <jb55@jb55.com>
Date:   Sat, 16 Apr 2022 08:29:44 -0700

NostrEvent: add local flags for internal use

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Nostr/NostrEvent.swift | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift @@ -27,6 +27,9 @@ class NostrEvent: Codable, Identifiable { // cached field for pow calc var pow: Int? + // custom flags for internal use + var flags: Int = 0 + let pubkey: String let created_at: Int64 let kind: Int @@ -36,6 +39,17 @@ class NostrEvent: Codable, Identifiable { case id, sig, tags, pubkey, created_at, kind, content } + /// Make a local event + public static func local(content: String, pubkey: String) -> NostrEvent { + let ev = NostrEvent(content: content, pubkey: pubkey) + ev.flags |= 1 + return ev + } + + public var is_local: Bool { + return (self.flags & 1) != 0 + } + init(content: String, pubkey: String, kind: Int = 1, tags: [[String]] = []) { self.id = "" self.sig = ""