mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Prevent multiple FR conversations
This commit is contained in:
parent
c7b76dfebb
commit
60ddaa14be
|
@ -87,6 +87,9 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('[vince] Creating conversation with id:', id);
|
||||||
|
|
||||||
|
|
||||||
if (!this._initialFetchComplete) {
|
if (!this._initialFetchComplete) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'ConversationController.get() needs complete initial fetch'
|
'ConversationController.get() needs complete initial fetch'
|
||||||
|
@ -194,6 +197,12 @@
|
||||||
conversations.remove(conversation);
|
conversations.remove(conversation);
|
||||||
},
|
},
|
||||||
getOrCreateAndWait(id, type) {
|
getOrCreateAndWait(id, type) {
|
||||||
|
const ourNumber = textsecure.storage.user.getNumber();
|
||||||
|
|
||||||
|
if (id !== ourNumber) {
|
||||||
|
console.log('[vince][core] getOrCreateAndWaiting.. with source:', id);
|
||||||
|
}
|
||||||
|
|
||||||
return this._initialPromise.then(() => {
|
return this._initialPromise.then(() => {
|
||||||
const conversation = this.getOrCreate(id, type);
|
const conversation = this.getOrCreate(id, type);
|
||||||
|
|
||||||
|
|
|
@ -584,7 +584,6 @@
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
|
||||||
isArchived: this.get('isArchived'),
|
isArchived: this.get('isArchived'),
|
||||||
activeAt: this.get('active_at'),
|
activeAt: this.get('active_at'),
|
||||||
avatarPath: this.getAvatarPath(),
|
avatarPath: this.getAvatarPath(),
|
||||||
|
@ -1620,6 +1619,8 @@
|
||||||
FriendRequestStatusEnum.pendingSend
|
FriendRequestStatusEnum.pendingSend
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Always share our profileKey in the friend request
|
// Always share our profileKey in the friend request
|
||||||
// This will get added automatically after the FR
|
// This will get added automatically after the FR
|
||||||
// is accepted, via the profileSharing flag
|
// is accepted, via the profileSharing flag
|
||||||
|
@ -1637,6 +1638,9 @@
|
||||||
direction: 'outgoing',
|
direction: 'outgoing',
|
||||||
friendStatus: 'pending',
|
friendStatus: 'pending',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`[vince][core] Sending FR message from conversations.js`, messageWithSchema);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isPrivate()) {
|
if (this.isPrivate()) {
|
||||||
|
@ -1658,6 +1662,9 @@
|
||||||
|
|
||||||
const model = this.addSingleMessage(attributes);
|
const model = this.addSingleMessage(attributes);
|
||||||
const message = MessageController.register(model.id, model);
|
const message = MessageController.register(model.id, model);
|
||||||
|
|
||||||
|
console.log('[vince][core] Sending message:', message);
|
||||||
|
|
||||||
await window.Signal.Data.saveMessage(message.attributes, {
|
await window.Signal.Data.saveMessage(message.attributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
|
|
|
@ -429,6 +429,10 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.set({ friendStatus: 'accepted' });
|
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, {
|
await window.Signal.Data.saveMessage(this.attributes, {
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
|
@ -2219,6 +2223,7 @@
|
||||||
let attributes = {
|
let attributes = {
|
||||||
...conversation.attributes,
|
...conversation.attributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (dataMessage.group) {
|
if (dataMessage.group) {
|
||||||
let groupUpdate = null;
|
let groupUpdate = null;
|
||||||
attributes = {
|
attributes = {
|
||||||
|
@ -2508,6 +2513,7 @@
|
||||||
- We are friends with the user,
|
- We are friends with the user,
|
||||||
and that user just sent us a friend request.
|
and that user just sent us a friend request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const isFriend = sendingDeviceConversation.isFriend();
|
const isFriend = sendingDeviceConversation.isFriend();
|
||||||
const hasSentFriendRequest = sendingDeviceConversation.hasSentFriendRequest();
|
const hasSentFriendRequest = sendingDeviceConversation.hasSentFriendRequest();
|
||||||
autoAccept = isFriend || hasSentFriendRequest;
|
autoAccept = isFriend || hasSentFriendRequest;
|
||||||
|
@ -2515,6 +2521,12 @@
|
||||||
if (autoAccept) {
|
if (autoAccept) {
|
||||||
message.set({ friendStatus: 'accepted' });
|
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(
|
libloki.api.debug.logNormalFriendRequest(
|
||||||
`Received a NORMAL_FRIEND_REQUEST from source: ${source}, primarySource: ${primarySource}, isAlreadyFriend: ${isFriend}, didWeAlreadySentFR: ${hasSentFriendRequest}`
|
`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
|
// 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) {
|
if (source !== ourNumber) {
|
||||||
message.set({ source: primarySource });
|
message.set({ source: conditionalSource });
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = await window.Signal.Data.saveMessage(message.attributes, {
|
const id = await window.Signal.Data.saveMessage(message.attributes, {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"start-multi2": "cross-env NODE_APP_INSTANCE=2 electron .",
|
"start-multi2": "cross-env NODE_APP_INSTANCE=2 electron .",
|
||||||
"start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod 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": "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": "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-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 .",
|
"start-swarm-test-3": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=3 electron .",
|
||||||
|
|
|
@ -123,6 +123,8 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
|
||||||
const item = receivedFriendsRequest[index];
|
const item = receivedFriendsRequest[index];
|
||||||
const onClick = this.props.openConversationInternal;
|
const onClick = this.props.openConversationInternal;
|
||||||
|
|
||||||
|
console.log('[vince] renderRowFriendRequest: receivedFriendsRequest:', receivedFriendsRequest);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConversationListItem
|
<ConversationListItem
|
||||||
key={key}
|
key={key}
|
||||||
|
|
|
@ -97,7 +97,7 @@ export class LeftPaneMessageSection extends React.Component<Props, any> {
|
||||||
if (conversationList !== undefined) {
|
if (conversationList !== undefined) {
|
||||||
conversationList = conversationList.filter(
|
conversationList = conversationList.filter(
|
||||||
conversation =>
|
conversation =>
|
||||||
!conversation.isSecondary && !conversation.isPendingFriendRequest
|
!conversation.isPendingFriendRequest
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ export type ConversationType = {
|
||||||
isFriend?: boolean;
|
isFriend?: boolean;
|
||||||
isSecondary?: boolean;
|
isSecondary?: boolean;
|
||||||
primaryDevice: string;
|
primaryDevice: string;
|
||||||
|
isPendingFriendRequest?: boolean;
|
||||||
hasReceivedFriendRequest?: boolean;
|
hasReceivedFriendRequest?: boolean;
|
||||||
hasSentFriendRequest?: boolean;
|
hasSentFriendRequest?: boolean;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue