remove FR logic from receiver and background.js

pull/1178/head
Audric Ackermann 5 years ago
parent f500fed69c
commit 68b119fb69
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -12,6 +12,7 @@
libsignal, libsignal,
StringView, StringView,
BlockedNumberController, BlockedNumberController,
libsession,
*/ */
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
@ -526,10 +527,7 @@
); );
// Make sure we only target outgoing messages // Make sure we only target outgoing messages
if ( if (message.isEndSession() && message.get('direction') === 'incoming') {
message.isFriendRequest() &&
message.get('direction') === 'incoming'
) {
return; return;
} }
@ -804,10 +802,6 @@
convo.updateGroupAdmins([primary]); convo.updateGroupAdmins([primary]);
convo.updateGroup(ev.groupDetails); convo.updateGroup(ev.groupDetails);
convo.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
appView.openConversation(groupId, {}); appView.openConversation(groupId, {});
// Subscribe to this group id // Subscribe to this group id
@ -846,12 +840,6 @@
convo.updateGroupAdmins([primaryDeviceKey]); convo.updateGroupAdmins([primaryDeviceKey]);
convo.updateGroup(ev.groupDetails); convo.updateGroup(ev.groupDetails);
// Group conversations are automatically 'friends'
// so that we can skip the friend request logic
convo.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
textsecure.messaging.sendGroupSyncMessage([convo]); textsecure.messaging.sendGroupSyncMessage([convo]);
appView.openConversation(groupId, {}); appView.openConversation(groupId, {});
}; };
@ -1148,11 +1136,6 @@
// convert conversation to a public one // convert conversation to a public one
await conversation.setPublicSource(sslServerURL, channelId); await conversation.setPublicSource(sslServerURL, channelId);
// set friend and appropriate SYNC messages for multidevice
await conversation.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends,
{ blockSync: true }
);
// and finally activate it // and finally activate it
conversation.getPublicSendData(); // may want "await" if you want to use the API conversation.getPublicSendData(); // may want "await" if you want to use the API
@ -1249,9 +1232,6 @@
serverAPI.findOrCreateChannel(channelId, conversationId); serverAPI.findOrCreateChannel(channelId, conversationId);
await conversation.setPublicSource(sslServerUrl, channelId); await conversation.setPublicSource(sslServerUrl, channelId);
await conversation.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
appView.openConversation(conversationId, {}); appView.openConversation(conversationId, {});
} }
@ -1596,10 +1576,6 @@
messageReceiver.addEventListener('configuration', onConfiguration); messageReceiver.addEventListener('configuration', onConfiguration);
messageReceiver.addEventListener('typing', onTyping); messageReceiver.addEventListener('typing', onTyping);
Whisper.events.on('endSession', source => {
messageReceiver.handleEndSession(source);
});
window.Signal.AttachmentDownloads.start({ window.Signal.AttachmentDownloads.start({
getMessageReceiver: () => messageReceiver, getMessageReceiver: () => messageReceiver,
logger: window.log, logger: window.log,
@ -1838,13 +1814,12 @@
ConversationController.getOrCreateAndWait(d, 'private') ConversationController.getOrCreateAndWait(d, 'private')
) )
); );
// triger session request with every devices of that user
// when we do not have a session with it already
deviceConversations.forEach(device => { deviceConversations.forEach(device => {
if (device.isFriendRequestStatusNoneOrExpired()) { libsession.Protocols.SessionProtocol.sendSessionRequestIfNeeded(
libloki.api.sendAutoFriendRequestMessage(device.id); libsession.Types.PubKey(device.id)
} else { );
// Accept any pending friend requests if there are any
device.onAcceptFriendRequest({ blockSync: true });
}
}); });
if (details.profileKey) { if (details.profileKey) {
@ -2180,7 +2155,7 @@
async function initIncomingMessage(data, options = {}) { async function initIncomingMessage(data, options = {}) {
const { isError } = options; const { isError } = options;
let messageData = { const messageData = {
source: data.source, source: data.source,
sourceDevice: data.sourceDevice, sourceDevice: data.sourceDevice,
serverId: data.serverId, serverId: data.serverId,
@ -2194,15 +2169,6 @@
isRss: data.isRss, isRss: data.isRss,
}; };
if (data.friendRequest) {
messageData = {
...messageData,
type: 'friend-request',
friendStatus: 'pending',
direction: 'incoming',
};
}
const message = new Whisper.Message(messageData); const message = new Whisper.Message(messageData);
// Send a delivery receipt // Send a delivery receipt
@ -2212,7 +2178,7 @@
const shouldSendReceipt = const shouldSendReceipt =
!isError && !isError &&
data.unidentifiedDeliveryReceived && data.unidentifiedDeliveryReceived &&
!data.friendRequest && !data.isSessionRequest &&
!isGroup; !isGroup;
// Send the receipt async and hope that it succeeds // Send the receipt async and hope that it succeeds

@ -12,7 +12,6 @@
Whisper, Whisper,
clipboard, clipboard,
libloki, libloki,
lokiFileServerAPI,
*/ */
/* eslint-disable more/no-then */ /* eslint-disable more/no-then */
@ -105,8 +104,6 @@
this.propsForGroupNotification = this.getPropsForGroupNotification(); this.propsForGroupNotification = this.getPropsForGroupNotification();
} else if (this.isSessionRestoration()) { } else if (this.isSessionRestoration()) {
// do nothing // do nothing
} else if (this.isFriendRequest()) {
this.propsForFriendRequest = this.getPropsForFriendRequest();
} else if (this.isGroupInvitation()) { } else if (this.isGroupInvitation()) {
this.propsForGroupInvitation = this.getPropsForGroupInvitation(); this.propsForGroupInvitation = this.getPropsForGroupInvitation();
} else { } else {
@ -282,9 +279,7 @@
isKeyChange() { isKeyChange() {
return this.get('type') === 'keychange'; return this.get('type') === 'keychange';
}, },
isFriendRequest() { isFriendRequest() {
// FIXME exclude session request to be seen as a session request
return this.get('type') === 'friend-request'; return this.get('type') === 'friend-request';
}, },
isGroupInvitation() { isGroupInvitation() {
@ -303,9 +298,6 @@
getNotificationText() { getNotificationText() {
const description = this.getDescription(); const description = this.getDescription();
if (description) { if (description) {
if (this.isFriendRequest()) {
return `Friend Request: ${description}`;
}
return description; return description;
} }
if (this.get('attachments').length > 0) { if (this.get('attachments').length > 0) {
@ -413,124 +405,6 @@
sessionResetMessageKey: this.getEndSessionTranslationKey(), sessionResetMessageKey: this.getEndSessionTranslationKey(),
}; };
}, },
async acceptFriendRequest() {
if (this.get('friendStatus') !== 'pending') {
return;
}
const devicePubKey = this.get('conversationId');
const otherDevices = await libloki.storage.getPairedDevicesFor(
devicePubKey
);
const allDevices = [devicePubKey, ...otherDevices];
// Set profile name to primary conversation
let profileName;
const allConversationsWithUser = allDevices
.map(d => ConversationController.get(d))
.filter(c => Boolean(c));
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;
}
profileName = conversation.getProfileName() || profileName;
conversation.onAcceptFriendRequest();
});
// If you don't have a profile name for this device, and profileName is set,
// add profileName to conversation.
const primaryDevicePubKey =
(await window.Signal.Data.getPrimaryDeviceFor(devicePubKey)) ||
devicePubKey;
const primaryConversation = allConversationsWithUser.find(
c => c.id === primaryDevicePubKey
);
if (!primaryConversation.getProfileName() && profileName) {
await primaryConversation.setNickname(profileName);
}
await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message,
});
this.set({ friendStatus: 'accepted' });
// Update redux store
window.Signal.Data.updateConversation(
primaryConversation.id,
primaryConversation.attributes,
{ Conversation: Whisper.Conversation }
);
},
async declineFriendRequest() {
if (this.get('friendStatus') !== 'pending') {
return;
}
this.set({ friendStatus: 'declined' });
await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message,
});
const devicePubKey = this.attributes.conversationId;
const otherDevices = await libloki.storage.getPairedDevicesFor(
devicePubKey
);
const allDevices = [devicePubKey, ...otherDevices];
const allConversationsWithUser = allDevices
.map(d => ConversationController.get(d))
.filter(c => Boolean(c));
allConversationsWithUser.forEach(conversation => {
conversation.onDeclineFriendRequest();
});
},
getPropsForFriendRequest() {
const friendStatus = this.get('friendStatus') || 'pending';
const direction = this.get('direction') || 'incoming';
const conversation = this.getConversation();
const onAccept = () => this.acceptFriendRequest();
const onDecline = () => this.declineFriendRequest();
const onRetrySend = () => this.retrySend();
const onDeleteConversation = async () => {
// Delete the whole conversation
window.Whisper.events.trigger('deleteConversation', conversation);
};
const onBlockUser = () => {
conversation.block();
this.trigger('change');
};
const onUnblockUser = () => {
conversation.unblock();
this.trigger('change');
};
return {
text: this.createNonBreakingLastSeparator(this.get('body')),
timestamp: this.get('sent_at'),
status: this.getMessagePropStatus(),
direction,
friendStatus,
isBlocked: conversation.isBlocked(),
onAccept,
onDecline,
onDeleteConversation,
onBlockUser,
onUnblockUser,
onRetrySend,
};
},
getPropsForGroupInvitation() { getPropsForGroupInvitation() {
const invitation = this.get('groupInvitation'); const invitation = this.get('groupInvitation');
@ -651,11 +525,7 @@
return 'error'; return 'error';
} }
// Handle friend request statuses const isOutgoing = this.isOutgoing();
const isFriendRequest = this.isFriendRequest();
const isOutgoingFriendRequest =
isFriendRequest && this.get('direction') === 'outgoing';
const isOutgoing = this.isOutgoing() || isOutgoingFriendRequest;
// Only return the status on outgoing messages // Only return the status on outgoing messages
if (!isOutgoing) { if (!isOutgoing) {
@ -1487,7 +1357,8 @@
}); });
this.trigger('sent', this); this.trigger('sent', this);
if (!this.isFriendRequest()) { // don't send sync message for EndSession messages
if (!this.isEndSession()) {
const c = this.getConversation(); const c = this.getConversation();
// Don't bother sending sync messages to public chats // Don't bother sending sync messages to public chats
// or groups with sender keys // or groups with sender keys
@ -1954,50 +1825,6 @@
return message; return message;
}, },
async handleSecondaryDeviceFriendRequest(pubKey) {
// fetch the device mapping from the server
const deviceMapping = await lokiFileServerAPI.getUserDeviceMapping(
pubKey
);
if (!deviceMapping) {
return false;
}
// Only handle secondary pubkeys
if (deviceMapping.isPrimary === '1' || !deviceMapping.authorisations) {
return false;
}
const { authorisations } = deviceMapping;
// Secondary devices should only have 1 authorisation from a primary device
if (authorisations.length !== 1) {
return false;
}
const authorisation = authorisations[0];
if (!authorisation) {
return false;
}
if (!authorisation.grantSignature) {
return false;
}
const isValid = await libloki.crypto.validateAuthorisation(authorisation);
if (!isValid) {
return false;
}
const correctSender = pubKey === authorisation.secondaryDevicePubKey;
if (!correctSender) {
return false;
}
const { primaryDevicePubKey } = authorisation;
// ensure the primary device is a friend
const c = window.ConversationController.get(primaryDevicePubKey);
if (!c || !(await c.isFriendWithAnyDevice())) {
return false;
}
await libloki.storage.savePairingAuthorisation(authorisation);
return true;
},
/** /**
* Returns true if the message is already completely handled and confirmed * Returns true if the message is already completely handled and confirmed
* and the processing of this message must stop. * and the processing of this message must stop.
@ -2013,9 +1840,13 @@
return true; return true;
} }
// NOTE: we use friends status to tell if this is // NOTE: we use group admins to tell if this is
// the creation of the group (initial update) // the creation of the group (initial update)
const newGroup = !conversation.isFriend(); const groupAdminsSet =
conversation.get('groupAdmins') &&
conversation.get('groupAdmins').length > 0;
const newGroup = !groupAdminsSet;
const knownMembers = conversation.get('members'); const knownMembers = conversation.get('members');
if (!newGroup && knownMembers) { if (!newGroup && knownMembers) {
@ -2046,10 +1877,6 @@
) { ) {
if (newGroup) { if (newGroup) {
conversation.updateGroupAdmins(initialMessage.group.admins); conversation.updateGroupAdmins(initialMessage.group.admins);
conversation.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
} else { } else {
// be sure to drop a message from a non admin if it tries to change group members // be sure to drop a message from a non admin if it tries to change group members
// or change the group name // or change the group name
@ -2097,11 +1924,6 @@
} }
return false; return false;
}, },
async handleSessionRequest(source, confirm) {
window.console.log(`Received SESSION_REQUEST from source: ${source}`);
window.libloki.api.sendSessionEstablishedMessage(source);
confirm();
},
isGroupBlocked(groupId) { isGroupBlocked(groupId) {
return textsecure.storage.get('blocked-groups', []).indexOf(groupId) >= 0; return textsecure.storage.get('blocked-groups', []).indexOf(groupId) >= 0;
}, },
@ -2120,47 +1942,6 @@
return groupId && isBlocked && !(isMe && isLeavingGroup); return groupId && isBlocked && !(isMe && isLeavingGroup);
}, },
async handleAutoFriendRequestMessage(
source,
ourPubKey,
conversation,
confirm
) {
const isMe = source === ourPubKey;
// If we got a friend request message (session request excluded) or
// if we're not friends with the current user that sent this private message
// Check to see if we need to auto accept their friend request
if (isMe) {
window.log.info('refusing to add a friend request to ourselves');
throw new Error('Cannot add a friend request for ourselves!');
} else {
// auto-accept friend request if the device is paired to one of our friend's primary device
const shouldAutoAcceptFR = await this.handleSecondaryDeviceFriendRequest(
source
);
if (shouldAutoAcceptFR) {
libloki.api.debug.logAutoFriendRequest(
`Received AUTO_FRIEND_REQUEST from source: ${source}`
);
// Directly setting friend request status to skip the pending state
await conversation.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
// sending a message back = accepting friend request
window.libloki.api.sendBackgroundMessage(
source,
window.textsecure.OutgoingMessage.DebugMessageType.AUTO_FR_ACCEPT
);
confirm();
// return true to notify the message is fully processed
return true;
}
}
return false;
},
async handleDataMessage(initialMessage, confirm) { async handleDataMessage(initialMessage, confirm) {
// This function is called from the background script in a few scenarios: // This function is called from the background script in a few scenarios:
// 1. on an incoming message // 1. on an incoming message
@ -2213,43 +1994,6 @@
// Show that the session reset is "in progress" even though we had a valid session // Show that the session reset is "in progress" even though we had a valid session
this.set({ endSessionType: 'ongoing' }); this.set({ endSessionType: 'ongoing' });
} }
/**
* A session request message is a friend-request message with the flag
* SESSION_REQUEST set to true.
*/
const sessionRequestFlag =
textsecure.protobuf.DataMessage.Flags.SESSION_REQUEST;
/* eslint-disable no-bitwise */
if (
message.isFriendRequest() &&
!!(initialMessage.flags & sessionRequestFlag)
) {
await this.handleSessionRequest(source, confirm);
// Wether or not we accepted the FR, we exit early so session requests
// cannot be used for establishing regular private conversations
return null;
}
/* eslint-enable no-bitwise */
// Session request have been dealt with before, so a friend request here is
// not a session request message. Also, handleAutoFriendRequestMessage() only handles the autoAccept logic of an auto friend request.
if (
message.isFriendRequest() ||
(!isGroupMessage && !conversationOrigin.isFriend())
) {
const shouldReturn = await this.handleAutoFriendRequestMessage(
source,
ourNumber,
conversationOrigin,
confirm
);
// handleAutoFriendRequestMessage can process fully a message in some cases
// so we need to return early if that's the case
if (shouldReturn) {
return null;
}
}
return conversationPrimary.queueJob(async () => { return conversationPrimary.queueJob(async () => {
window.log.info( window.log.info(
@ -2453,7 +2197,7 @@
: 'done'; : 'done';
this.set({ endSessionType }); this.set({ endSessionType });
} }
if (type === 'incoming' || message.isFriendRequest()) { if (type === 'incoming' || message.isEndSession()) {
const readSync = Whisper.ReadSyncs.forMessage(message); const readSync = Whisper.ReadSyncs.forMessage(message);
if (readSync) { if (readSync) {
if ( if (
@ -2535,54 +2279,6 @@
} }
} }
let autoAccept = false;
// Make sure friend request logic doesn't trigger on messages aimed at groups
if (!isGroupMessage) {
// We already handled (and returned) session request and auto Friend Request before,
// so that can only be a normal Friend Request
if (message.isFriendRequest()) {
/*
Here is the before and after state diagram for the operation before.
None -> RequestReceived
PendingSend -> RequestReceived
RequestReceived -> RequestReceived
Sent -> Friends
Expired -> Friends
Friends -> Friends
The cases where we auto accept are the following:
- We sent the user a friend request,
and that user sent us a friend request.
- We are friends with the user,
and that user just sent us a friend request.
*/
const isFriend = conversationOrigin.isFriend();
const hasSentFriendRequest = conversationOrigin.hasSentFriendRequest();
autoAccept = isFriend || hasSentFriendRequest;
if (autoAccept) {
message.set({ friendStatus: 'accepted' });
}
libloki.api.debug.logNormalFriendRequest(
`Received a NORMAL_FRIEND_REQUEST from source: ${source}, primarySource: ${primarySource}, isAlreadyFriend: ${isFriend}, didWeAlreadySentFR: ${hasSentFriendRequest}`
);
if (isFriend) {
window.Whisper.events.trigger('endSession', source);
} else if (hasSentFriendRequest) {
await conversationOrigin.onFriendRequestAccepted();
} else {
await conversationOrigin.onFriendRequestReceived();
}
} else if (message.get('type') !== 'outgoing') {
// Ignore 'outgoing' messages because they are sync messages
await conversationOrigin.onFriendRequestAccepted();
}
}
// We need to map the original message source to the primary device // We need to map the original message source to the primary device
if (source !== ourNumber) { if (source !== ourNumber) {
message.set({ source: primarySource }); message.set({ source: primarySource });
@ -2641,12 +2337,7 @@
} }
if (message.get('unread')) { if (message.get('unread')) {
// Need to do this here because the conversation has already changed states await conversationPrimary.notify(message);
if (autoAccept) {
await conversationPrimary.notifyFriendRequest(source, 'accepted');
} else {
await conversationPrimary.notify(message);
}
} }
confirm(); confirm();

@ -173,8 +173,6 @@
color: this.model.getColor(), color: this.model.getColor(),
avatarPath: this.model.getAvatarPath(), avatarPath: this.model.getAvatarPath(),
isVerified: this.model.isVerified(), isVerified: this.model.isVerified(),
isFriendRequestPending: this.model.isPendingFriendRequest(),
isFriend: this.model.isFriend(),
isMe: this.model.isMe(), isMe: this.model.isMe(),
isClosable: this.model.isClosable(), isClosable: this.model.isClosable(),
isBlocked: this.model.isBlocked(), isBlocked: this.model.isBlocked(),

@ -745,7 +745,7 @@ MessageReceiver.prototype.extend({
promise = this.decryptForMediumGroup(envelope, ciphertext); promise = this.decryptForMediumGroup(envelope, ciphertext);
break; break;
case textsecure.protobuf.Envelope.Type.SESSION_REQUEST: { case textsecure.protobuf.Envelope.Type.SESSION_REQUEST: {
window.log.info('friend-request message from ', envelope.source); window.log.info('session-request message from ', envelope.source);
const fallBackSessionCipher = new libloki.crypto.FallBackSessionCipher( const fallBackSessionCipher = new libloki.crypto.FallBackSessionCipher(
address address
@ -1035,7 +1035,7 @@ MessageReceiver.prototype.extend({
); );
// Set current device as secondary. // Set current device as secondary.
// This will ensure the authorisation is sent // This will ensure the authorisation is sent
// along with each friend request. // along with each session request.
window.storage.remove('secondaryDeviceStatus'); window.storage.remove('secondaryDeviceStatus');
window.storage.put('isSecondaryDevice', true); window.storage.put('isSecondaryDevice', true);
window.storage.put('primaryDevicePubKey', primaryDevicePubKey); window.storage.put('primaryDevicePubKey', primaryDevicePubKey);
@ -1325,10 +1325,6 @@ MessageReceiver.prototype.extend({
convo.set('name', groupName); convo.set('name', groupName);
convo.set('groupAdmins', admins); convo.set('groupAdmins', admins);
convo.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
const secretKeyHex = StringView.arrayBufferToHex( const secretKeyHex = StringView.arrayBufferToHex(
groupSecretKey.toArrayBuffer() groupSecretKey.toArrayBuffer()
); );
@ -1398,6 +1394,7 @@ MessageReceiver.prototype.extend({
const conversation = window.ConversationController.get(senderPubKey); const conversation = window.ConversationController.get(senderPubKey);
const { UNPAIRING_REQUEST } = textsecure.protobuf.DataMessage.Flags; const { UNPAIRING_REQUEST } = textsecure.protobuf.DataMessage.Flags;
const { SESSION_REQUEST } = textsecure.protobuf.Envelope.Type;
// eslint-disable-next-line no-bitwise // eslint-disable-next-line no-bitwise
const isUnpairingRequest = Boolean(message.flags & UNPAIRING_REQUEST); const isUnpairingRequest = Boolean(message.flags & UNPAIRING_REQUEST);
@ -1421,17 +1418,6 @@ MessageReceiver.prototype.extend({
return this.removeFromCache(envelope); return this.removeFromCache(envelope);
} }
// Loki - Temp hack until new protocol
// A friend request is a non-group text message which we haven't processed yet
const isGroupMessage = Boolean(message.group || message.mediumGroupUpdate);
const friendRequestStatusNoneOrExpired = conversation
? conversation.isFriendRequestStatusNoneOrExpired()
: true;
const isFriendRequest =
!isGroupMessage &&
!_.isEmpty(message.body) &&
friendRequestStatusNoneOrExpired;
const source = envelope.senderIdentity || senderPubKey; const source = envelope.senderIdentity || senderPubKey;
const isOwnDevice = async pubkey => { const isOwnDevice = async pubkey => {
@ -1464,7 +1450,7 @@ MessageReceiver.prototype.extend({
ev.confirm = this.removeFromCache.bind(this, envelope); ev.confirm = this.removeFromCache.bind(this, envelope);
ev.data = { ev.data = {
friendRequest: isFriendRequest, isSessionRequest: envelope.type === SESSION_REQUEST,
source, source,
sourceDevice: envelope.sourceDevice, sourceDevice: envelope.sourceDevice,
timestamp: envelope.timestamp.toNumber(), timestamp: envelope.timestamp.toNumber(),
@ -1521,37 +1507,16 @@ MessageReceiver.prototype.extend({
} }
return this.innerHandleContentMessage(envelope, plaintext); return this.innerHandleContentMessage(envelope, plaintext);
}, },
async handleFriendRequestAcceptIfNeeded(envelope, content) {
const isGroupMessage =
content &&
content.dataMessage &&
(content.dataMessage.group || content.dataMessage.mediumGroupUpdate);
const isReceiptMessage = content && content.receiptMessage;
const isTypingMessage = content && content.typingMessage;
if (isGroupMessage || isReceiptMessage || isTypingMessage) {
return;
}
// If we sent a friend request and got another message back then we should become friends
try {
const conversation = await window.ConversationController.getOrCreateAndWait(
envelope.source,
'private'
);
const isFriendRequestAccept = await conversation.onFriendRequestAccepted();
if (isFriendRequestAccept) {
await conversation.notifyFriendRequest(envelope.source, 'accepted');
}
} catch (e) {
window.log.info('Error getting conversation: ', envelope.source);
}
},
async handleSessionRequestMessage(envelope, content) { async handleSessionRequestMessage(envelope, content) {
const shouldProcessSessionRequest = await libsession.Protocols.SessionProtocol.shouldProcessSessionRequest( const shouldProcessSessionRequest = await libsession.Protocols.SessionProtocol.shouldProcessSessionRequest(
envelope.source, envelope.source,
envelope.timestamp envelope.timestamp
); );
window.console.log(
`Received SESSION_REQUEST from source: ${envelope.source}`
);
if (shouldProcessSessionRequest) { if (shouldProcessSessionRequest) {
try { try {
// TODO remember to remove savePreKeyBundleMessage() from the codebase if it's actually irrelevant // TODO remember to remove savePreKeyBundleMessage() from the codebase if it's actually irrelevant
@ -1615,8 +1580,6 @@ MessageReceiver.prototype.extend({
// TODO process sending queue for this device now that we have a session // TODO process sending queue for this device now that we have a session
} }
this.handleFriendRequestAcceptIfNeeded(envelope, content);
if (content.pairingAuthorisation) { if (content.pairingAuthorisation) {
return this.handlePairingAuthorisationMessage(envelope, content); return this.handlePairingAuthorisationMessage(envelope, content);
} }

@ -621,12 +621,7 @@ OutgoingMessage.prototype = {
if (!outgoingObject) { if (!outgoingObject) {
return; return;
} }
const { const { pubKey: destination, ttl, isSessionRequest } = outgoingObject;
pubKey: destination,
ttl,
isFriendRequest,
isSessionRequest,
} = outgoingObject;
try { try {
const socketMessage = wrapInWebsocketMessage( const socketMessage = wrapInWebsocketMessage(
@ -640,7 +635,7 @@ OutgoingMessage.prototype = {
ttl ttl
); );
if (!this.isGroup && isFriendRequest && !isSessionRequest) { if (!this.isGroup && !isSessionRequest) {
const conversation = ConversationController.get(destination); const conversation = ConversationController.get(destination);
if (conversation) { if (conversation) {
// Redundant for primary device but marks secondary devices as pending // Redundant for primary device but marks secondary devices as pending

@ -57,8 +57,6 @@ interface Props {
hasNickname?: boolean; hasNickname?: boolean;
isBlocked: boolean; isBlocked: boolean;
isFriend: boolean;
isFriendRequestPending: boolean;
isOnline?: boolean; isOnline?: boolean;
selectedMessages: any; selectedMessages: any;
@ -138,13 +136,11 @@ export class ConversationHeader extends React.Component<Props> {
phoneNumber, phoneNumber,
i18n, i18n,
profileName, profileName,
isFriend,
isGroup, isGroup,
isPublic, isPublic,
isRss, isRss,
members, members,
subscriberCount, subscriberCount,
isFriendRequestPending,
isMe, isMe,
isKickedFromGroup, isKickedFromGroup,
name, name,
@ -171,11 +167,7 @@ export class ConversationHeader extends React.Component<Props> {
})(); })();
let text = ''; let text = '';
if (isFriendRequestPending) { if (isGroup && memberCount > 0) {
text = i18n('pendingAcceptance');
} else if (!isFriend && !isGroup) {
text = i18n('notFriends');
} else if (memberCount > 0) {
const count = String(memberCount); const count = String(memberCount);
text = i18n('members', [count]); text = i18n('members', [count]);
} }
@ -439,7 +431,6 @@ export class ConversationHeader extends React.Component<Props> {
isBlocked, isBlocked,
isMe, isMe,
isGroup, isGroup,
isFriend,
isKickedFromGroup, isKickedFromGroup,
isPublic, isPublic,
isRss, isRss,
@ -461,7 +452,7 @@ export class ConversationHeader extends React.Component<Props> {
const blockTitle = isBlocked ? i18n('unblockUser') : i18n('blockUser'); const blockTitle = isBlocked ? i18n('unblockUser') : i18n('blockUser');
const blockHandler = isBlocked ? onUnblockUser : onBlockUser; const blockHandler = isBlocked ? onUnblockUser : onBlockUser;
const disappearingMessagesMenuItem = isFriend && !isKickedFromGroup && ( const disappearingMessagesMenuItem = !isKickedFromGroup && (
<SubMenu title={disappearingTitle}> <SubMenu title={disappearingTitle}>
{(timerOptions || []).map(item => ( {(timerOptions || []).map(item => (
<MenuItem <MenuItem
@ -484,7 +475,7 @@ export class ConversationHeader extends React.Component<Props> {
{i18n('showSafetyNumber')} {i18n('showSafetyNumber')}
</MenuItem> </MenuItem>
); );
const resetSessionMenuItem = isFriend && !isGroup && ( const resetSessionMenuItem = !isGroup && (
<MenuItem onClick={onResetSession}>{i18n('resetSession')}</MenuItem> <MenuItem onClick={onResetSession}>{i18n('resetSession')}</MenuItem>
); );
const blockHandlerMenuItem = !isMe && !isGroup && !isRss && ( const blockHandlerMenuItem = !isMe && !isGroup && !isRss && (

Loading…
Cancel
Save