Fix friend request messages being sent to users you don't have a session in closed groups.

Disable typing messages and read receipts in groups.
Send out session request messages if you don't have a session with a member in the group.
pull/789/head
Mikunj 5 years ago
parent 9104144922
commit c9f60826b4

@ -2112,13 +2112,16 @@
const { wrap, sendOptions } = ConversationController.prepareForSend( const { wrap, sendOptions } = ConversationController.prepareForSend(
data.source data.source
); );
await wrap( const isGroup = data && data.message && data.message.group;
textsecure.messaging.sendDeliveryReceipt( if (!isGroup) {
data.source, await wrap(
data.timestamp, textsecure.messaging.sendDeliveryReceipt(
sendOptions data.source,
) data.timestamp,
); sendOptions
)
);
}
} catch (error) { } catch (error) {
window.log.error( window.log.error(
`Failed to send delivery receipt to ${data.source} for message ${ `Failed to send delivery receipt to ${data.source} for message ${

@ -382,6 +382,11 @@
}, },
sendTypingMessage(isTyping) { sendTypingMessage(isTyping) {
// Loki - Temporarily disable typing messages for groups
if (!this.isPrivate()) {
return;
}
const groupId = !this.isPrivate() ? this.id : null; const groupId = !this.isPrivate() ? this.id : null;
const recipientId = this.isPrivate() ? this.id : null; const recipientId = this.isPrivate() ? this.id : null;
const groupNumbers = this.getRecipients(); const groupNumbers = this.getRecipients();
@ -1518,11 +1523,14 @@
now now
); );
const conversationType = this.get('type');
let messageWithSchema = null; let messageWithSchema = null;
// If we are a friend with any of the devices, send the message normally // If we are a friend with any of the devices, send the message normally
const canSendNormalMessage = await this.isFriendWithAnyDevice(); const canSendNormalMessage = await this.isFriendWithAnyDevice();
if (canSendNormalMessage) { const isGroup = conversationType === Message.GROUP;
if (canSendNormalMessage || isGroup) {
messageWithSchema = await upgradeMessageSchema({ messageWithSchema = await upgradeMessageSchema({
type: 'outgoing', type: 'outgoing',
body, body,
@ -1668,8 +1676,6 @@
return message.sendSyncMessageOnly(dataMessage); return message.sendSyncMessageOnly(dataMessage);
} }
const conversationType = this.get('type');
const options = this.getSendOptions(); const options = this.getSendOptions();
options.messageType = message.get('type'); options.messageType = message.get('type');
options.isPublic = this.isPublic(); options.isPublic = this.isPublic();
@ -2321,7 +2327,7 @@
return; return;
} }
if (!this.isPublic() && read.length && options.sendReadReceipts) { if (this.isPrivate() && read.length && options.sendReadReceipts) {
window.log.info(`Sending ${read.length} read receipts`); window.log.info(`Sending ${read.length} read receipts`);
// Because syncReadMessages sends to our other devices, and sendReadReceipts goes // Because syncReadMessages sends to our other devices, and sendReadReceipts goes
// to a contact, we need accessKeys for both. // to a contact, we need accessKeys for both.

@ -72,6 +72,11 @@ function OutgoingMessage(
options || {}; options || {};
this.numberInfo = numberInfo; this.numberInfo = numberInfo;
this.isPublic = isPublic; this.isPublic = isPublic;
this.isGroup = !!(
this.message &&
this.message.dataMessage &&
this.message.dataMessage.group
);
this.publicSendData = publicSendData; this.publicSendData = publicSendData;
this.senderCertificate = senderCertificate; this.senderCertificate = senderCertificate;
this.online = online; this.online = online;
@ -348,7 +353,8 @@ OutgoingMessage.prototype = {
if ( if (
conversation && conversation &&
!conversation.isFriend() && !conversation.isFriend() &&
!conversation.hasReceivedFriendRequest() !conversation.hasReceivedFriendRequest() &&
!this.isGroup
) { ) {
// We want to send an automated friend request if: // We want to send an automated friend request if:
// - We aren't already friends // - We aren't already friends

@ -409,6 +409,8 @@ MessageSender.prototype = {
options options
); );
const ourNumber = textsecure.storage.user.getNumber();
numbers.forEach(number => { numbers.forEach(number => {
// Note: if we are sending a private group message, we do our best to // Note: if we are sending a private group message, we do our best to
// ensure we have signal protocol sessions with every member, but if we // ensure we have signal protocol sessions with every member, but if we
@ -419,7 +421,7 @@ MessageSender.prototype = {
); );
if ( if (
number === textsecure.storage.user.getNumber() || number === ourNumber ||
haveSession || haveSession ||
options.isPublic || options.isPublic ||
options.messageType === 'friend-request' options.messageType === 'friend-request'
@ -427,6 +429,20 @@ MessageSender.prototype = {
this.queueJobForNumber(number, () => outgoing.sendToNumber(number)); this.queueJobForNumber(number, () => outgoing.sendToNumber(number));
} else { } else {
window.log.error(`No session for number: ${number}`); window.log.error(`No session for number: ${number}`);
// If it was a message to a group then we need to send a session request
if (outgoing.isGroup && number !== ourNumber) {
this.sendMessageToNumber(
number,
'(If you see this message, you must be using an out-of-date client)',
[],
undefined,
[],
Date.now(),
undefined,
undefined,
{ messageType: 'friend-request', sessionRequest: true }
);
}
} }
}); });
}, },

Loading…
Cancel
Save