diff --git a/src/components/FileList/index.tsx b/src/components/FileList/index.tsx
index 62f3119..317a0e8 100644
--- a/src/components/FileList/index.tsx
+++ b/src/components/FileList/index.tsx
@@ -16,6 +16,7 @@ interface FileListProps {
setCurrentFile: (file: CurrentUserFile) => void
handleExport?: () => void
handleEncryptedExport?: () => void
+ reBroadcastSigit?: () => void
}
const FileList = ({
@@ -23,7 +24,8 @@ const FileList = ({
currentFile,
setCurrentFile,
handleExport,
- handleEncryptedExport
+ handleEncryptedExport,
+ reBroadcastSigit
}: FileListProps) => {
const isActive = (file: CurrentUserFile) => file.id === currentFile.id
return (
@@ -91,6 +93,12 @@ const FileList = ({
)}
)}
+
+ {typeof reBroadcastSigit === 'function' && (
+
+ )}
)
}
diff --git a/src/pages/verify/index.tsx b/src/pages/verify/index.tsx
index d80671d..63de48f 100644
--- a/src/pages/verify/index.tsx
+++ b/src/pages/verify/index.tsx
@@ -28,7 +28,8 @@ import {
ARRAY_BUFFER,
DEFLATE,
uploadMetaToFileStorage,
- decrypt
+ decrypt,
+ SignStatus
} from '../../utils'
import styles from './style.module.scss'
import { useLocation, useParams } from 'react-router-dom'
@@ -217,6 +218,7 @@ export const VerifyPage = () => {
encryptionKey,
signers,
viewers,
+ signersStatus,
fileHashes,
parsedSignatureEvents,
timestamps
@@ -732,6 +734,76 @@ export const VerifyPage = () => {
return Promise.resolve(arrayBuffer)
}
+ const reBroadcastSigit = async () => {
+ const usersNpub = hexToNpub(usersPubkey!)
+
+ if (!encryptionKey) {
+ toast.error('Encryption key is missing')
+ return
+ }
+
+ setIsLoading(true)
+ setLoadingSpinnerDesc('storing meta on blossom server')
+
+ let metaUrl: string
+ try {
+ metaUrl = await uploadMetaToFileStorage(meta, encryptionKey)
+ } catch (error) {
+ if (error instanceof Error) {
+ toast.error(error.message)
+ }
+ console.error(error)
+ setIsLoading(false)
+ return
+ }
+
+ const userSet = new Set<`npub1${string}`>()
+ if (submittedBy && submittedBy !== usersPubkey) {
+ userSet.add(hexToNpub(submittedBy))
+ }
+
+ // add all the signers who have signed and next signer to userSet
+ signers.forEach((signer) => {
+ // skip current user
+ if (signer === usersNpub) return
+
+ if (signersStatus[signer] === SignStatus.Signed) {
+ userSet.add(signer)
+ } else if (signersStatus[signer] === SignStatus.Awaiting) {
+ userSet.add(signer)
+ }
+ })
+
+ // If all signers have signed then include viewers too
+ if (
+ signers.every((signer) => signersStatus[signer] === SignStatus.Signed)
+ ) {
+ viewers.forEach((viewer) => {
+ // skip current user
+ if (viewer === usersNpub) return
+
+ userSet.add(viewer)
+ })
+ }
+
+ setLoadingSpinnerDesc('Sending notifications')
+ const users = Array.from(userSet)
+ const promises = users.map((user) =>
+ sendNotification(npubToHex(user)!, { metaUrl, keys: meta.keys })
+ )
+
+ await Promise.all(promises)
+ .then(() => {
+ toast.success('Notifications sent successfully')
+ setMeta(meta)
+ })
+ .catch(() => {
+ toast.error('Failed to publish notifications')
+ })
+
+ setIsLoading(false)
+ }
+
return (
<>
{isLoading && }
@@ -780,6 +852,7 @@ export const VerifyPage = () => {
setCurrentFile={setCurrentFile}
handleExport={handleExport}
handleEncryptedExport={handleEncryptedExport}
+ reBroadcastSigit={reBroadcastSigit}
/>
)
}