From 9a3a933dc52ddedf4f6381288c6ffa7ccc266e1a Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 31 Dec 2022 20:28:04 -0500 Subject: [PATCH] *If we are setting the entry, only respond if successful *If we are skipping the set, respond --- src/index.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/index.ts b/src/index.ts index 098bef4..31ad686 100644 --- a/src/index.ts +++ b/src/index.ts @@ -109,19 +109,22 @@ const plugin: Plugin = { let entry = (await getEntry(newEntry.pk)) as SignedRegistryEntry; async function setAndRespond(entry: SignedRegistryEntry, set = true) { + let ret = true; if (set) { - await setEntry(newEntry); + ret = await setEntry(newEntry); + } + if (ret) { + sendDirectOrBroadcast( + Message.create({ + type: MessageType.CREATED, + pubkey: entry.pk, + revision: entry.revision, + signature: entry.signature, + data: entry.data, + }), + origin + ); } - sendDirectOrBroadcast( - Message.create({ - type: MessageType.CREATED, - pubkey: entry.pk, - revision: entry.revision, - signature: entry.signature, - data: entry.data, - }), - origin - ); } if (entry) {