diff --git a/lib/handlers/db-ops-handler.react.js b/lib/handlers/db-ops-handler.react.js --- a/lib/handlers/db-ops-handler.react.js +++ b/lib/handlers/db-ops-handler.react.js @@ -11,6 +11,8 @@ peerToPeerMessageTypes, } from '../types/tunnelbroker/peer-to-peer-message-types.js'; import { getConfig } from '../utils/config.js'; +import { getContentSigningKey } from '../utils/crypto-utils.js'; +import { getMessageForException } from '../utils/errors.js'; import { useDispatch, useSelector } from '../utils/redux-utils.js'; type Props = { @@ -41,16 +43,26 @@ type: opsProcessingFinishedActionType, }); if (messageSourceMetadata) { - const { messageID, senderDeviceID } = messageSourceMetadata; - const message: MessageProcessed = { - type: peerToPeerMessageTypes.MESSAGE_PROCESSED, - messageID, - }; - await sendMessage({ - deviceID: senderDeviceID, - payload: JSON.stringify(message), - }); - await sqliteAPI.removeInboundP2PMessages([messageID]); + try { + const { messageID, senderDeviceID } = messageSourceMetadata; + const deviceID = await getContentSigningKey(); + const message: MessageProcessed = { + type: peerToPeerMessageTypes.MESSAGE_PROCESSED, + messageID, + deviceID, + }; + await sendMessage({ + deviceID: senderDeviceID, + payload: JSON.stringify(message), + }); + await sqliteAPI.removeInboundP2PMessages([messageID]); + } catch (e) { + console.log( + `Error while sending confirmation: ${ + getMessageForException(e) ?? 'unknown error' + }`, + ); + } } })(); }, [queueFront, dispatch, processDBStoreOperations, sendMessage, sqliteAPI]); diff --git a/lib/types/tunnelbroker/peer-to-peer-message-types.js b/lib/types/tunnelbroker/peer-to-peer-message-types.js --- a/lib/types/tunnelbroker/peer-to-peer-message-types.js +++ b/lib/types/tunnelbroker/peer-to-peer-message-types.js @@ -91,11 +91,13 @@ export type MessageProcessed = { +type: 'MessageProcessed', +messageID: string, + +deviceID: string, }; export const messageProcessedValidator: TInterface = tShape({ type: tString(peerToPeerMessageTypes.MESSAGE_PROCESSED), messageID: t.String, + deviceID: t.String, }); export type PeerToPeerMessage =