*If we are setting the entry, only respond if successful

*If we are skipping the set, respond
This commit is contained in:
Derrick Hammer 2022-12-31 20:28:04 -05:00
parent c734832952
commit 9a3a933dc5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 11 deletions

View File

@ -109,19 +109,22 @@ const plugin: Plugin = {
let entry = (await getEntry(newEntry.pk)) as SignedRegistryEntry; let entry = (await getEntry(newEntry.pk)) as SignedRegistryEntry;
async function setAndRespond(entry: SignedRegistryEntry, set = true) { async function setAndRespond(entry: SignedRegistryEntry, set = true) {
let ret = true;
if (set) { 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) { if (entry) {