Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3350743
D13005.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13005.diff
View Options
diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js
--- a/lib/shared/dm-ops/dm-op-utils.js
+++ b/lib/shared/dm-ops/dm-op-utils.js
@@ -2,7 +2,6 @@
import uuid from 'uuid';
-import type { AuxUserStore } from '../../types/aux-user-types.js';
import type { DMOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import type { RawMessageInfo } from '../../types/message-types.js';
@@ -17,21 +16,22 @@
import type { ClientUpdateInfo } from '../../types/update-types.js';
import type { CurrentUserInfo } from '../../types/user-types.js';
import { getContentSigningKey } from '../../utils/crypto-utils.js';
-import { values } from '../../utils/objects.js';
import { messageSpecs } from '../messages/message-specs.js';
function generateMessagesToPeers(
message: DMOperation,
- peers: $ReadOnlyArray<string>,
- userID: string,
+ peers: $ReadOnlyArray<{
+ +userID: string,
+ +deviceID: string,
+ }>,
supportsAutoRetry: boolean,
): $ReadOnlyArray<OutboundP2PMessage> {
const outboundP2PMessages = [];
- for (const peerID of peers) {
+ for (const peer of peers) {
const messageToPeer: OutboundP2PMessage = {
messageID: uuid.v4(),
- deviceID: peerID,
- userID,
+ deviceID: peer.deviceID,
+ userID: peer.userID,
timestamp: new Date().getTime().toString(),
plaintext: JSON.stringify(message),
ciphertext: '',
@@ -51,25 +51,30 @@
async function createMessagesToPeersFromDMOp(
operation: DMOperationSpecification,
- auxUserStore: AuxUserStore,
+ allPeerUserIDAndDeviceIDs: $ReadOnlyArray<{
+ +userID: string,
+ +deviceID: string,
+ }>,
currentUserInfo: ?CurrentUserInfo,
): Promise<$ReadOnlyArray<OutboundP2PMessage>> {
if (!currentUserInfo?.id) {
return [];
}
- const selfDevices =
- auxUserStore.auxUserInfos[currentUserInfo.id].deviceList?.devices ?? [];
- const allPeerDevices = values(auxUserStore.auxUserInfos)
- .map(info => info.deviceList?.devices ?? [])
- .flat();
- const devices =
- operation.recipients === 'all_peer_devices' ? allPeerDevices : selfDevices;
+
+ let peerUserIDAndDeviceIDs = allPeerUserIDAndDeviceIDs;
+ if (operation.recipients === 'self_devices') {
+ peerUserIDAndDeviceIDs = allPeerUserIDAndDeviceIDs.filter(
+ peer => peer.userID === currentUserInfo.id,
+ );
+ }
+
const thisDeviceID = await getContentSigningKey();
- const targetDevices = devices.filter(id => id !== thisDeviceID);
+ const targetPeers = peerUserIDAndDeviceIDs.filter(
+ peer => peer.deviceID !== thisDeviceID,
+ );
return generateMessagesToPeers(
operation.op,
- targetDevices,
- currentUserInfo.id,
+ targetPeers,
operation.supportsAutoRetry,
);
}
diff --git a/lib/tunnelbroker/peer-to-peer-context.js b/lib/tunnelbroker/peer-to-peer-context.js
--- a/lib/tunnelbroker/peer-to-peer-context.js
+++ b/lib/tunnelbroker/peer-to-peer-context.js
@@ -9,6 +9,7 @@
useTunnelbroker,
} from './tunnelbroker-context.js';
import { usePeerOlmSessionsCreatorContext } from '../components/peer-olm-session-creator-provider.react.js';
+import { getAllPeerUserIDAndDeviceIDs } from '../selectors/user-selectors.js';
import {
createMessagesToPeersFromDMOp,
type DMOperationSpecification,
@@ -169,7 +170,7 @@
const dmOpsSendingPromiseResolvers = React.useRef<
Map<string, { +resolve: () => mixed, +reject: Error => mixed }>,
>(new Map());
- const auxUserStore = useSelector(state => state.auxUserStore);
+ const allPeerUserIDAndDeviceIDs = useSelector(getAllPeerUserIDAndDeviceIDs);
const currentUserInfo = useSelector(state => state.currentUserInfo);
const sendDMOperation = React.useCallback(
@@ -181,7 +182,7 @@
const messages = await createMessagesToPeersFromDMOp(
op,
- auxUserStore,
+ allPeerUserIDAndDeviceIDs,
currentUserInfo,
);
dispatch({
@@ -194,7 +195,7 @@
return promise;
},
- [auxUserStore, currentUserInfo, dispatch],
+ [allPeerUserIDAndDeviceIDs, currentUserInfo, dispatch],
);
const processingQueue = React.useRef<
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 11:48 PM (18 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2572868
Default Alt Text
D13005.diff (4 KB)
Attached To
Mode
D13005: [lib] fix usage of `userID` in DMOp messages
Attached
Detach File
Event Timeline
Log In to Comment