Merge branch 'clearnet' of https://github.com/loki-project/session-desktop into refactor-ts-react

pull/1279/head
Vincent 5 years ago
commit 704d5a1184

@ -243,16 +243,6 @@
);
});
},
prepareForSend(id) {
// id is either a group id or an individual user's id
const conversation = this.get(id);
const sendOptions = {};
const wrap = conversation
? conversation.wrapSend.bind(conversation)
: promise => promise;
return { wrap, sendOptions };
},
async getAllGroupsInvolvingId(id) {
const groups = await window.Signal.Data.getAllGroupsInvolvingId(id, {
ConversationCollection: Whisper.ConversationCollection,

@ -136,7 +136,7 @@ window.onerror = (message, script, line, col, error) => {
};
window.addEventListener('unhandledrejection', rejectionEvent => {
window.log.error(
`Top-level unhandled promise rejection: ${rejectionEvent.reason}`
);
const error = rejectionEvent.reason;
const errorInfo = error && error.stack ? error.stack : JSON.stringify(error);
window.log.error(`Top-level unhandled promise rejection: ${errorInfo}`);
});

@ -746,17 +746,8 @@
}
},
async sendVerifySyncMessage(number, state) {
// Because syncVerification sends a (null) message to the target of the verify and
// 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,
{ syncMessage: true }
);
const options = Object.assign({}, sendOptions, {});
const key = await textsecure.storage.protocol.loadIdentityKey(number);
return textsecure.messaging.syncVerification(number, state, key, options);
return textsecure.messaging.syncVerification(number, state, key);
},
isVerified() {
if (this.isPrivate()) {
@ -1465,30 +1456,6 @@
}
});
},
wrapSend(promise) {
return promise.then(
async result => {
// success
if (result) {
await this.handleMessageSendResult({
...result,
success: true,
});
}
return result;
},
async result => {
// failure
if (result) {
await this.handleMessageSendResult({
...result,
success: false,
});
}
throw result;
}
);
},
async updateAvatarOnPublicChat({ url, profileKey }) {
if (!this.isPublic()) {
@ -1510,63 +1477,6 @@
);
await serverAPI.setAvatar(url, profileKey);
},
async handleMessageSendResult({ failoverNumbers, unidentifiedDeliveries }) {
await Promise.all(
(failoverNumbers || []).map(async number => {
const conversation = ConversationController.get(number);
if (
conversation &&
conversation.get('sealedSender') !== SEALED_SENDER.DISABLED
) {
window.log.info(
`Setting sealedSender to DISABLED for conversation ${conversation.idForLogging()}`
);
conversation.set({
sealedSender: SEALED_SENDER.DISABLED,
});
await window.Signal.Data.updateConversation(
conversation.id,
conversation.attributes,
{ Conversation: Whisper.Conversation }
);
}
})
);
await Promise.all(
(unidentifiedDeliveries || []).map(async number => {
const conversation = ConversationController.get(number);
if (
conversation &&
conversation.get('sealedSender') === SEALED_SENDER.UNKNOWN
) {
if (conversation.get('accessKey')) {
window.log.info(
`Setting sealedSender to ENABLED for conversation ${conversation.idForLogging()}`
);
conversation.set({
sealedSender: SEALED_SENDER.ENABLED,
});
} else {
window.log.info(
`Setting sealedSender to UNRESTRICTED for conversation ${conversation.idForLogging()}`
);
conversation.set({
sealedSender: SEALED_SENDER.UNRESTRICTED,
});
}
await window.Signal.Data.updateConversation(
conversation.id,
conversation.attributes,
{ Conversation: Whisper.Conversation }
);
}
})
);
},
async updateLastMessage() {
if (!this.id) {
return;
@ -2195,31 +2105,26 @@
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 { sendOptions } = ConversationController.prepareForSend(
this.ourNumber,
{ syncMessage: true }
);
await textsecure.messaging.syncReadMessages(read, sendOptions);
// FIXME AUDRIC
// if (storage.get('read-receipt-setting')) {
// await Promise.all(
// _.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
// const timestamps = _.map(receipts, 'timestamp');
// const receiptMessage = new libsession.Messages.Outgoing.ReadReceiptMessage(
// {
// timestamp: Date.now(),
// timestamps,
// }
// );
// const device = new libsession.Types.PubKey(sender);
// await libsession
// .getMessageQueue()
// .sendUsingMultiDevice(device, receiptMessage);
// })
// );
// }
await textsecure.messaging.syncReadMessages(read);
if (storage.get('read-receipt-setting')) {
await Promise.all(
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
const timestamps = _.map(receipts, 'timestamp');
const receiptMessage = new libsession.Messages.Outgoing.ReadReceiptMessage(
{
timestamp: Date.now(),
timestamps,
}
);
const device = new libsession.Types.PubKey(sender);
await libsession
.getMessageQueue()
.sendUsingMultiDevice(device, receiptMessage);
})
);
}
}
},

@ -21,7 +21,7 @@
"grunt": "grunt",
"icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build",
"generate": "yarn icon-gen && yarn grunt",
"build-release": "cross-env SIGNAL_ENV=production npm run build -- --config.directories.output=release",
"build-release": "cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release",
"build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long",
"clean-module-protobuf": "rm -f ts/protobuf/compiled.d.ts ts/protobuf/compiled.js",
"build-protobuf": "yarn build-module-protobuf",

@ -14,6 +14,8 @@ import { handleUnpairRequest } from './multidevice';
import { downloadAttachment } from './attachments';
import _ from 'lodash';
import { StringUtils } from '../session/utils';
import { DeliveryReceiptMessage } from '../session/messages/outgoing';
import { getMessageQueue } from '../session';
export async function updateProfile(
conversation: any,
@ -528,13 +530,12 @@ function createMessage(
}
function sendDeliveryReceipt(source: string, timestamp: any) {
// FIXME audric
// const receiptMessage = new DeliveryReceiptMessage({
// timestamp: Date.now(),
// timestamps: [timestamp],
// });
// const device = new PubKey(source);
// await getMessageQueue().sendUsingMultiDevice(device, receiptMessage);
const receiptMessage = new DeliveryReceiptMessage({
timestamp: Date.now(),
timestamps: [timestamp],
});
const device = new PubKey(source);
void getMessageQueue().sendUsingMultiDevice(device, receiptMessage);
}
interface MessageEvent {
@ -631,7 +632,20 @@ export async function handleMessageEvent(event: MessageEvent): Promise<void> {
);
}
await window.ConversationController.getOrCreateAndWait(conversationId, type);
const conv = await window.ConversationController.getOrCreateAndWait(
conversationId,
type
);
if (!isGroupMessage && !isIncoming) {
const primaryDestination = await MultiDeviceProtocol.getPrimaryDevice(
destination
);
if (destination !== primaryDestination.key) {
// mark created conversation as secondary if this is one
conv.setSecondaryStatus(true, primaryDestination.key);
}
}
// =========== Process flags =============

Loading…
Cancel
Save