Page MenuHomePhabricator

D13032.diff
No OneTemporary

D13032.diff

diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
--- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js
+++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
@@ -4,6 +4,7 @@
import _isEqual from 'lodash/fp/isEqual.js';
import * as React from 'react';
+import { useResendPeerToPeerMessages } from './use-resend-peer-to-peer-messages.js';
import { removePeerUsersActionType } from '../actions/aux-user-actions.js';
import { invalidateTunnelbrokerDeviceTokenActionType } from '../actions/tunnelbroker-actions.js';
import { logOutActionTypes, useLogOut } from '../actions/user-actions.js';
@@ -171,6 +172,7 @@
const dispatch = useDispatch();
const handleOlmMessageToDevice = useHandleOlmMessageToDevice();
+ const resendPeerToPeerMessages = useResendPeerToPeerMessages();
return React.useCallback(
async (message: PeerToPeerMessage, messageID: string) => {
@@ -235,8 +237,7 @@
`${senderDeviceID}: ${result}, ` +
`session version: ${sessionVersion}`,
);
- // Resend all not-yet confirmed messages that were encrypted
- // with overwrite session. Tracked in ENG-6982.
+ await resendPeerToPeerMessages(senderDeviceID);
}
} else {
console.log(
@@ -381,6 +382,7 @@
handleOlmMessageToDevice,
identityClient,
olmAPI,
+ resendPeerToPeerMessages,
sqliteAPI,
],
);
diff --git a/lib/tunnelbroker/use-resend-peer-to-peer-messages.js b/lib/tunnelbroker/use-resend-peer-to-peer-messages.js
new file mode 100644
--- /dev/null
+++ b/lib/tunnelbroker/use-resend-peer-to-peer-messages.js
@@ -0,0 +1,22 @@
+// @flow
+
+import * as React from 'react';
+
+import { usePeerToPeerCommunication } from './peer-to-peer-context.js';
+import { getConfig } from '../utils/config.js';
+
+function useResendPeerToPeerMessages(): (deviceID: string) => Promise<void> {
+ const { sqliteAPI } = getConfig();
+ const { processOutboundMessages } = usePeerToPeerCommunication();
+
+ return React.useCallback(
+ async (deviceID: string) => {
+ const messageIDs =
+ await sqliteAPI.resetOutboundP2PMessagesForDevice(deviceID);
+ processOutboundMessages(messageIDs);
+ },
+ [processOutboundMessages, sqliteAPI],
+ );
+}
+
+export { useResendPeerToPeerMessages };

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 7:43 PM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585936
Default Alt Text
D13032.diff (2 KB)

Event Timeline