wip: Send dm on sigit sign/complete #230

Draft
enes wants to merge 3 commits from 92-send-completion-dm into staging
Showing only changes of commit 3b4bf9aa29 - Show all commits

View File

@ -716,25 +716,21 @@ export const CreatePage = () => {
toast.error('Failed to publish notifications') toast.error('Failed to publish notifications')
}) })
// Send DM to the next signer
setLoadingSpinnerDesc('Sending DMs') setLoadingSpinnerDesc('Sending DMs')
// Send DM to signers and viewers if (signers.length > 0 && signers[0].pubkey !== usersPubkey) {
// No need to send notification to self so remove it from the list // No need to send notification to self so remove it from the list
const receivers = ( const nextSigner = signers[0].pubkey
signers.length > 0
? [signers[0].pubkey]
: viewers.map((viewer) => viewer.pubkey)
).filter((receiver) => receiver !== usersPubkey)
for (let i = 0; i < receivers.length; i++) { if (nextSigner) {
const createSignatureEvent = await parseNostrEvent( const createSignatureEvent = await parseNostrEvent(
meta.createSignature meta.createSignature
) )
const { id } = createSignatureEvent const { id } = createSignatureEvent
const r = receivers[i]
try { try {
await sendPrivateDirectMessage( await sendPrivateDirectMessage(
`Sigit created, visit ${window.location.origin}/#/${signers.length > 0 ? 'sign' : 'verify'}/${id}`, `Sigit created, visit ${window.location.origin}/#/sign/${id}`,
npubToHex(r!)! npubToHex(nextSigner)!
) )
} catch (error) { } catch (error) {
if (error instanceof SendDMError) { if (error instanceof SendDMError) {
@ -743,6 +739,7 @@ export const CreatePage = () => {
console.error(error) console.error(error)
} }
} }
}
navigate(appPrivateRoutes.sign, { state: { meta } }) navigate(appPrivateRoutes.sign, { state: { meta } })
} else { } else {