Accepting FR from each conv

pull/1138/head
Vincent 5 years ago
parent 8f08c2aabf
commit 9c7f5b2c09

@ -87,7 +87,6 @@
);
}
console.log('[vince] Creating conversation with id:', id);

@ -1004,7 +1004,6 @@
});
},
async respondToAllFriendRequests(options) {
const { response, status, direction = null } = options;
// Ignore if no response supplied
if (!response) {
@ -1020,13 +1019,8 @@
return;
}
console.log('[vince] allDevices:', allDevices);
const allConversationsWithUser = allDevices.map(d => ConversationController.get(d));
console.log('[vince][fr] allConversationsWithUser:', allConversationsWithUser);
console.log('[vince][fr] direction:', direction);
console.log(`[vince][fr] Status: `, status);
const pendingRequests = await allConversationsWithUser.reduce(async (requestsP, conversation) => {
const requests = await requestsP;
const request = (await conversation.getFriendRequests(direction, status))[0];
@ -1034,14 +1028,10 @@
return request ? requests.concat({ conversation, request }) : requests;
}, []);
console.log('[vince][fr] pendingRequests:', pendingRequests);
await Promise.all(
pendingRequests.map(async friendRequest => {
const { conversation, request } = friendRequest;
console.log('[vince][fr] friendRequest:', friendRequest);
if (request.hasErrors()) {
return;
}
@ -1053,7 +1043,6 @@
conversation.trigger('updateMessage', request);
})
);
},
async respondToAllPendingFriendRequests(options) {
return this.respondToAllFriendRequests({

@ -415,38 +415,34 @@
},
async acceptFriendRequest() {
// THIS FUNCTION RUNS WHEN "ACCEPT" BUTTON IN CHAT IS CLICKED
if (this.get('friendStatus') !== 'pending') {
return;
}
const conversation = await this.getSourceDeviceConversation();
console.log('[vince][fr] conversation:', conversation);
console.log('[vince][fr] sourceDeviceConversation():', await this.getSourceDeviceConversation());
// If we somehow received an old friend request (e.g. after having restored
// from seed, we won't be able to accept it, we should initiate our own
// friend request to reset the session:
if (conversation.get('sessionRestoreSeen')) {
conversation.sendMessage('', null, null, null, null, {
sessionRestoration: true,
});
return;
}
// TESTING turning this off
// this.set({ friendStatus: 'accepted' });
const allDevices = await libloki.storage.getAllDevicePubKeysForPrimaryPubKey(
this.attributes.conversationId
);
console.log('[vince][core] this.attributes:', this.attributes);
console.log('[vince][core] This is the conversation youre accepting!! :', conversation);
const allConversationsWithUser = allDevices.map(d => ConversationController.get(d));
allConversationsWithUser.forEach(conversation => {
// If we somehow received an old friend request (e.g. after having restored
// from seed, we won't be able to accept it, we should initiate our own
// friend request to reset the session:
if (conversation.get('sessionRestoreSeen')) {
conversation.sendMessage('', null, null, null, null, {
sessionRestoration: true,
});
return;
}
conversation.onAcceptFriendRequest();
});
await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message,
});
conversation.onAcceptFriendRequest();
this.set({ friendStatus: 'accepted' });
},
async declineFriendRequest() {
if (this.get('friendStatus') !== 'pending') {

Loading…
Cancel
Save