Refine Sealed Sender behaviors
This commit is contained in:
parent
8391f6ec4e
commit
2d48daa7b6
8 changed files with 59 additions and 32 deletions
|
@ -721,7 +721,8 @@
|
|||
|
||||
if (Whisper.Import.isComplete()) {
|
||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||
textsecure.storage.user.getNumber()
|
||||
textsecure.storage.user.getNumber(),
|
||||
{ syncMessage: true }
|
||||
);
|
||||
wrap(
|
||||
textsecure.messaging.sendRequestConfigurationSyncMessage(sendOptions)
|
||||
|
|
|
@ -181,10 +181,12 @@
|
|||
);
|
||||
});
|
||||
},
|
||||
prepareForSend(id) {
|
||||
prepareForSend(id, options) {
|
||||
// id is either a group id or an individual user's id
|
||||
const conversation = this.get(id);
|
||||
const sendOptions = conversation && conversation.getSendOptions();
|
||||
const sendOptions = conversation
|
||||
? conversation.getSendOptions(options)
|
||||
: null;
|
||||
const wrap = conversation
|
||||
? conversation.wrapSend.bind(conversation)
|
||||
: promise => promise;
|
||||
|
|
|
@ -342,10 +342,11 @@
|
|||
// a sync message to our own devices, we need to send the accessKeys down for both
|
||||
// contacts. So we merge their sendOptions.
|
||||
const { sendOptions } = ConversationController.prepareForSend(
|
||||
this.ourNumber
|
||||
this.ourNumber,
|
||||
{ syncMessage: true }
|
||||
);
|
||||
const recipientSendOptions = this.getSendOptions();
|
||||
const options = Object.assign({}, sendOptions, recipientSendOptions);
|
||||
const contactSendOptions = this.getSendOptions();
|
||||
const options = Object.assign({}, sendOptions, contactSendOptions);
|
||||
|
||||
const promise = textsecure.storage.protocol.loadIdentityKey(number);
|
||||
return promise.then(key =>
|
||||
|
@ -879,9 +880,9 @@
|
|||
);
|
||||
},
|
||||
|
||||
getSendOptions() {
|
||||
getSendOptions(options = {}) {
|
||||
const senderCertificate = storage.get('senderCertificate');
|
||||
const numberInfo = this.getNumberInfo();
|
||||
const numberInfo = this.getNumberInfo(options);
|
||||
|
||||
return {
|
||||
senderCertificate,
|
||||
|
@ -889,7 +890,10 @@
|
|||
};
|
||||
},
|
||||
|
||||
getNumberInfo({ disableMeCheck } = {}) {
|
||||
getNumberInfo(options = {}) {
|
||||
const { syncMessage, disableMeCheck } = options;
|
||||
|
||||
// START: this code has an Expiration date of ~2018/11/21
|
||||
// We don't want to enable unidentified delivery for send unless it is
|
||||
// also enabled for our own account.
|
||||
const me = ConversationController.getOrCreate(this.ourNumber, 'private');
|
||||
|
@ -899,10 +903,11 @@
|
|||
) {
|
||||
return null;
|
||||
}
|
||||
// END
|
||||
|
||||
if (!this.isPrivate()) {
|
||||
const infoArray = this.contactCollection.map(conversation =>
|
||||
conversation.getNumberInfo({ disableMeCheck })
|
||||
conversation.getNumberInfo(options)
|
||||
);
|
||||
return Object.assign({}, ...infoArray);
|
||||
}
|
||||
|
@ -910,6 +915,11 @@
|
|||
const accessKey = this.get('accessKey');
|
||||
const sealedSender = this.get('sealedSender');
|
||||
|
||||
// We never send sync messages as sealed sender
|
||||
if (syncMessage && this.id === this.ourNumber) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If we've never fetched user's profile, we default to what we have
|
||||
if (sealedSender === SEALED_SENDER.UNKNOWN) {
|
||||
return {
|
||||
|
@ -1243,19 +1253,17 @@
|
|||
window.log.info(`Sending ${read.length} read receipts`);
|
||||
// Because syncReadMessages sends to our other devices, and sendReadReceipts goes
|
||||
// to a contact, we need accessKeys for both.
|
||||
const prep = ConversationController.prepareForSend(this.ourNumber);
|
||||
const recipientSendOptions = this.getSendOptions();
|
||||
const sendOptions = Object.assign(
|
||||
{},
|
||||
prep.sendOptions,
|
||||
recipientSendOptions
|
||||
const { sendOptions } = ConversationController.prepareForSend(
|
||||
this.ourNumber,
|
||||
{ syncMessage: true }
|
||||
);
|
||||
|
||||
await this.wrapSend(
|
||||
textsecure.messaging.syncReadMessages(read, sendOptions)
|
||||
);
|
||||
|
||||
if (storage.get('read-receipt-setting')) {
|
||||
const convoSendOptions = this.getSendOptions();
|
||||
|
||||
await Promise.all(
|
||||
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
|
||||
const timestamps = _.map(receipts, 'timestamp');
|
||||
|
@ -1263,7 +1271,7 @@
|
|||
textsecure.messaging.sendReadReceipts(
|
||||
sender,
|
||||
timestamps,
|
||||
sendOptions
|
||||
convoSendOptions
|
||||
)
|
||||
);
|
||||
})
|
||||
|
|
|
@ -981,7 +981,8 @@
|
|||
sendSyncMessage() {
|
||||
const ourNumber = textsecure.storage.user.getNumber();
|
||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||
ourNumber
|
||||
ourNumber,
|
||||
{ syncMessage: true }
|
||||
);
|
||||
|
||||
this.syncPromise = this.syncPromise || Promise.resolve();
|
||||
|
|
|
@ -46,7 +46,9 @@ exports.syncReadReceiptConfiguration = async ({
|
|||
}
|
||||
|
||||
try {
|
||||
const { wrap, sendOptions } = prepareForSend(ourNumber);
|
||||
const { wrap, sendOptions } = prepareForSend(ourNumber, {
|
||||
syncMessage: true,
|
||||
});
|
||||
await wrap(sendRequestConfigurationSyncMessage(sendOptions));
|
||||
storage.put(settingName, true);
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const WebSocket = require('websocket').w3cwebsocket;
|
||||
const fetch = require('node-fetch');
|
||||
const ProxyAgent = require('proxy-agent');
|
||||
const { Agent } = require('https');
|
||||
|
||||
const is = require('@sindresorhus/is');
|
||||
|
||||
|
@ -159,6 +160,11 @@ function _createSocket(url, { certificateAuthority, proxyUrl }) {
|
|||
return new WebSocket(url, null, null, null, requestOptions);
|
||||
}
|
||||
|
||||
const agents = {
|
||||
unauth: null,
|
||||
auth: null,
|
||||
};
|
||||
|
||||
function _promiseAjax(providedUrl, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = providedUrl || `${options.host}/${options.path}`;
|
||||
|
@ -169,10 +175,16 @@ function _promiseAjax(providedUrl, options) {
|
|||
typeof options.timeout !== 'undefined' ? options.timeout : 10000;
|
||||
|
||||
const { proxyUrl } = options;
|
||||
let agent;
|
||||
const agentType = options.unathenticated ? 'unauth' : 'auth';
|
||||
|
||||
if (!agents[agentType]) {
|
||||
if (proxyUrl) {
|
||||
agent = new ProxyAgent(proxyUrl);
|
||||
agents[agentType] = new ProxyAgent(proxyUrl);
|
||||
} else {
|
||||
agents[agentType] = new Agent();
|
||||
}
|
||||
}
|
||||
const agent = agents[agentType];
|
||||
|
||||
const fetchOptions = {
|
||||
method: options.type,
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
const ourNumber = textsecure.storage.user.getNumber();
|
||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||
ourNumber
|
||||
ourNumber,
|
||||
{ syncMessage: true }
|
||||
);
|
||||
window.log.info('SyncRequest created. Sending contact sync message...');
|
||||
wrap(sender.sendRequestContactSyncMessage(sendOptions))
|
||||
|
|
|
@ -244,7 +244,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "js/background.js",
|
||||
"line": " wrap(",
|
||||
"lineNumber": 726,
|
||||
"lineNumber": 727,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-18T22:23:00.485Z"
|
||||
},
|
||||
|
@ -252,7 +252,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "js/background.js",
|
||||
"line": " await wrap(",
|
||||
"lineNumber": 1227,
|
||||
"lineNumber": 1228,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-26T22:43:23.229Z"
|
||||
},
|
||||
|
@ -260,7 +260,7 @@
|
|||
"rule": "jQuery-load(",
|
||||
"path": "js/conversation_controller.js",
|
||||
"line": " async load() {",
|
||||
"lineNumber": 208,
|
||||
"lineNumber": 210,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-02T21:00:44.007Z"
|
||||
},
|
||||
|
@ -268,7 +268,7 @@
|
|||
"rule": "jQuery-load(",
|
||||
"path": "js/conversation_controller.js",
|
||||
"line": " this._initialPromise = load();",
|
||||
"lineNumber": 237,
|
||||
"lineNumber": 239,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-02T21:00:44.007Z"
|
||||
},
|
||||
|
@ -311,7 +311,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "js/models/messages.js",
|
||||
"line": " return wrap(",
|
||||
"lineNumber": 993,
|
||||
"lineNumber": 994,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-05T23:12:28.961Z"
|
||||
},
|
||||
|
@ -383,7 +383,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "js/modules/startup.js",
|
||||
"line": " await wrap(sendRequestConfigurationSyncMessage(sendOptions));",
|
||||
"lineNumber": 50,
|
||||
"lineNumber": 52,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-05T23:12:28.961Z"
|
||||
},
|
||||
|
@ -2331,7 +2331,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "libtextsecure/sync_request.js",
|
||||
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
||||
"lineNumber": 31,
|
||||
"lineNumber": 32,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-05T23:12:28.961Z"
|
||||
},
|
||||
|
@ -2339,7 +2339,7 @@
|
|||
"rule": "jQuery-wrap(",
|
||||
"path": "libtextsecure/sync_request.js",
|
||||
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
||||
"lineNumber": 34,
|
||||
"lineNumber": 35,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2018-10-05T23:12:28.961Z"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue