Prevent multiple FR conversations

This commit is contained in:
Vincent 2020-05-19 11:12:05 +10:00
parent c7b76dfebb
commit 60ddaa14be
7 changed files with 40 additions and 4 deletions

View file

@ -87,6 +87,9 @@
);
}
console.log('[vince] Creating conversation with id:', id);
if (!this._initialFetchComplete) {
throw new Error(
'ConversationController.get() needs complete initial fetch'
@ -194,6 +197,12 @@
conversations.remove(conversation);
},
getOrCreateAndWait(id, type) {
const ourNumber = textsecure.storage.user.getNumber();
if (id !== ourNumber) {
console.log('[vince][core] getOrCreateAndWaiting.. with source:', id);
}
return this._initialPromise.then(() => {
const conversation = this.getOrCreate(id, type);

View file

@ -584,7 +584,6 @@
const result = {
id: this.id,
isArchived: this.get('isArchived'),
activeAt: this.get('active_at'),
avatarPath: this.getAvatarPath(),
@ -1620,6 +1619,8 @@
FriendRequestStatusEnum.pendingSend
);
// Always share our profileKey in the friend request
// This will get added automatically after the FR
// is accepted, via the profileSharing flag
@ -1637,6 +1638,9 @@
direction: 'outgoing',
friendStatus: 'pending',
});
console.log(`[vince][core] Sending FR message from conversations.js`, messageWithSchema);
}
if (this.isPrivate()) {
@ -1658,6 +1662,9 @@
const model = this.addSingleMessage(attributes);
const message = MessageController.register(model.id, model);
console.log('[vince][core] Sending message:', message);
await window.Signal.Data.saveMessage(message.attributes, {
forceSave: true,
Message: Whisper.Message,

View file

@ -429,6 +429,10 @@
return;
}
this.set({ friendStatus: 'accepted' });
console.log('[vince][core] this.attributes:', this.attributes);
console.log('[vince][core] This is the conversation youre accepting!! :', conversation);
await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message,
});
@ -2219,6 +2223,7 @@
let attributes = {
...conversation.attributes,
};
if (dataMessage.group) {
let groupUpdate = null;
attributes = {
@ -2508,6 +2513,7 @@
- We are friends with the user,
and that user just sent us a friend request.
*/
const isFriend = sendingDeviceConversation.isFriend();
const hasSentFriendRequest = sendingDeviceConversation.hasSentFriendRequest();
autoAccept = isFriend || hasSentFriendRequest;
@ -2515,6 +2521,12 @@
if (autoAccept) {
message.set({ friendStatus: 'accepted' });
}
console.log('[vince][core] source:', source);
console.log('[vince][core] ourNumber:', ourNumber);
console.log('[vince][core] Friend request in messaages.js:2391', message);
libloki.api.debug.logNormalFriendRequest(
`Received a NORMAL_FRIEND_REQUEST from source: ${source}, primarySource: ${primarySource}, isAlreadyFriend: ${isFriend}, didWeAlreadySentFR: ${hasSentFriendRequest}`
@ -2534,8 +2546,13 @@
}
// We need to map the original message source to the primary device
// only map to primary device if this is NOT a friend request.
// Otherwise you can enter a stalemate.
const conditionalSource = message.get('type') === 'friend-request'
? source
: primarySource;
if (source !== ourNumber) {
message.set({ source: primarySource });
message.set({ source: conditionalSource });
}
const id = await window.Signal.Data.saveMessage(message.attributes, {

View file

@ -20,7 +20,7 @@
"start-multi2": "cross-env NODE_APP_INSTANCE=2 electron .",
"start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod electron .",
"start-prod-multi": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod1 electron .",
"start-prod-multi-2": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod2 electron .",
"start-prod-multi1": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod2 electron .",
"start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=1 electron .",
"start-swarm-test-2": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=2 electron .",
"start-swarm-test-3": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=3 electron .",

View file

@ -123,6 +123,8 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
const item = receivedFriendsRequest[index];
const onClick = this.props.openConversationInternal;
console.log('[vince] renderRowFriendRequest: receivedFriendsRequest:', receivedFriendsRequest);
return (
<ConversationListItem
key={key}

View file

@ -97,7 +97,7 @@ export class LeftPaneMessageSection extends React.Component<Props, any> {
if (conversationList !== undefined) {
conversationList = conversationList.filter(
conversation =>
!conversation.isSecondary && !conversation.isPendingFriendRequest
!conversation.isPendingFriendRequest
);
}

View file

@ -55,6 +55,7 @@ export type ConversationType = {
isFriend?: boolean;
isSecondary?: boolean;
primaryDevice: string;
isPendingFriendRequest?: boolean;
hasReceivedFriendRequest?: boolean;
hasSentFriendRequest?: boolean;
};