From 96ed6b7cc7d496d438a8ee7b6314b3a9542a2bf6 Mon Sep 17 00:00:00 2001 From: Charlie Fish Date: Sat, 10 Feb 2024 09:36:46 -0700 Subject: [PATCH] mute: add maybe_get_content function to NdbNote MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a maybe_get_content method to NdbNote which returns an optional string instead of “*failed to decrypt content*” on DM decryption failure. This method will be used by the MutelistManager in future patches. Lighting-Address: fishcharlie@strike.me Signed-off-by: Charlie Fish Reviewed-by: William Casarin Link: 20240210163650.42884-2-contact@charlie.fish Signed-off-by: William Casarin --- nostrdb/NdbNote.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nostrdb/NdbNote.swift b/nostrdb/NdbNote.swift index 8ed33ee9..ba543a71 100644 --- a/nostrdb/NdbNote.swift +++ b/nostrdb/NdbNote.swift @@ -346,6 +346,14 @@ extension NdbNote { return content } + func maybe_get_content(_ keypair: Keypair) -> String? { + if known_kind == .dm { + return decrypted(keypair: keypair) + } + + return content + } + func blocks(_ keypair: Keypair) -> Blocks { return get_blocks(keypair: keypair) }