always add event.id

This commit is contained in:
fiatjaf
2021-12-28 20:44:35 -03:00
parent 7b0220c1b8
commit faa308049f

View File

@@ -95,11 +95,12 @@ export function relayPool(globalPrivateKey) {
if (index !== -1) noticeCallbacks.splice(index, 1) if (index !== -1) noticeCallbacks.splice(index, 1)
}, },
async publish(event, statusCallback = (status, relayURL) => {}) { async publish(event, statusCallback = (status, relayURL) => {}) {
event.id = await getEventHash(event)
if (!event.sig) { if (!event.sig) {
event.tags = event.tags || [] event.tags = event.tags || []
if (globalPrivateKey) { if (globalPrivateKey) {
event.id = await getEventHash(event)
event.sig = await signEvent(event, globalPrivateKey) event.sig = await signEvent(event, globalPrivateKey)
} else { } else {
throw new Error( throw new Error(