Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32168934
D12077.1765055669.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D12077.1765055669.diff
View Options
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
@@ -1,8 +1,10 @@
// @flow
+import invariant from 'invariant';
import * as React from 'react';
import { opsProcessingFinishedActionType } from '../actions/db-ops-actions.js';
+import { IdentityClientContext } from '../shared/identity-client-context.js';
import { useTunnelbroker } from '../tunnelbroker/tunnelbroker-context.js';
import type { DBOpsEntry } from '../types/db-ops-types.js';
import type { StoreOperations } from '../types/store-ops-types.js';
@@ -11,6 +13,7 @@
peerToPeerMessageTypes,
} from '../types/tunnelbroker/peer-to-peer-message-types.js';
import { getConfig } from '../utils/config.js';
+import { getMessageForException } from '../utils/errors.js';
import { useDispatch, useSelector } from '../utils/redux-utils.js';
type Props = {
@@ -23,6 +26,8 @@
const queueFront = useSelector(state => state.dbOpsStore.queuedOps[0]);
const prevQueueFront = React.useRef<?DBOpsEntry>(null);
const { sendMessage } = useTunnelbroker();
+ const identityContext = React.useContext(IdentityClientContext);
+ invariant(identityContext, 'Identity context should be set');
const dispatch = useDispatch();
@@ -41,19 +46,39 @@
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 identityContext.getAuthMetadata();
+ if (!deviceID) {
+ return;
+ }
+ 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]);
+ }, [
+ queueFront,
+ dispatch,
+ processDBStoreOperations,
+ sendMessage,
+ sqliteAPI,
+ identityContext,
+ ]);
return null;
}
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<MessageProcessed> =
tShape<MessageProcessed>({
type: tString(peerToPeerMessageTypes.MESSAGE_PROCESSED),
messageID: t.String,
+ deviceID: t.String,
});
export type PeerToPeerMessage =
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 9:14 PM (3 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840894
Default Alt Text
D12077.1765055669.diff (3 KB)
Attached To
Mode
D12077: [lib] add `deviceID` prop to Tunnelbroker's `MessageProcessed`
Attached
Detach File
Event Timeline
Log In to Comment