various changes to be reverted. kind of working session chats only.

pull/1183/head
Audric Ackermann 5 years ago
parent a67fa54587
commit aa797f6670
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -723,13 +723,15 @@
if (!this.contactCollection.length) { if (!this.contactCollection.length) {
return false; return false;
} }
console.log('this.contactCollection', this.contactCollection)
return this.contactCollection.every(contact => { //FIXME AUDRIC
if (contact.isMe()) { return true;
return true; // return this.contactCollection.every(contact => {
} // if (contact.isMe()) {
return contact.isVerified(); // return true;
}); // }
// return contact.isVerified();
// });
}, },
async getPrimaryConversation() { async getPrimaryConversation() {
if (!this.isSecondaryDevice()) { if (!this.isSecondaryDevice()) {
@ -2097,24 +2099,25 @@
textsecure.messaging.syncReadMessages(read, sendOptions) textsecure.messaging.syncReadMessages(read, sendOptions)
); );
if (storage.get('read-receipt-setting')) { // FIXME AUDRIC
await Promise.all( // if (storage.get('read-receipt-setting')) {
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => { // await Promise.all(
const timestamps = _.map(receipts, 'timestamp'); // _.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
const receiptMessage = new libsession.Messages.Outgoing.ReadReceiptMessage( // const timestamps = _.map(receipts, 'timestamp');
{ // const receiptMessage = new libsession.Messages.Outgoing.ReadReceiptMessage(
timestamp: Date.now(), // {
timestamps, // timestamp: Date.now(),
} // timestamps,
); // }
// );
const device = new libsession.Types.PubKey(sender);
await libsession // const device = new libsession.Types.PubKey(sender);
.getMessageQueue() // await libsession
.sendUsingMultiDevice(device, receiptMessage); // .getMessageQueue()
}) // .sendUsingMultiDevice(device, receiptMessage);
); // })
} // );
// }
} }
}, },

@ -490,7 +490,7 @@ class LokiSnodeAPI {
// this function may be called concurrently make sure we only have one inflight // this function may be called concurrently make sure we only have one inflight
return primitives.allowOnlyOneAtATime( return primitives.allowOnlyOneAtATime(
'buildNewOnionPaths', 'buildNewOnionPaths',
this.buildNewOnionPathsWorker () => this.buildNewOnionPathsWorker()
); );
} }

@ -389,14 +389,6 @@ MessageSender.prototype = {
silent, silent,
options = {} options = {}
) { ) {
const rejections = textsecure.storage.get('signedKeyRotationRejected', 0);
if (rejections > 5) {
throw new textsecure.SignedPreKeyRotationError(
numbers,
message.toArrayBuffer(),
timestamp
);
}
// Note: Since we're just doing independant tasks, // Note: Since we're just doing independant tasks,
// using `async` in the `forEach` loop should be fine. // using `async` in the `forEach` loop should be fine.
@ -529,135 +521,138 @@ MessageSender.prototype = {
}, },
async sendContactSyncMessage(conversations) { async sendContactSyncMessage(conversations) {
// If we havn't got a primaryDeviceKey then we are in the middle of pairing return Promise.resolve();
// primaryDevicePubKey is set to our own number if we are the master device
const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
if (!primaryDeviceKey) {
return Promise.resolve();
}
// first get all friends with primary devices
const sessionContactsPrimary =
conversations.filter(
c =>
c.isPrivate() &&
!c.isOurLocalDevice() &&
!c.isBlocked() &&
!c.get('secondaryStatus')
) || [];
// then get all friends with secondary devices
let sessionContactsSecondary = conversations.filter(
c =>
c.isPrivate() &&
!c.isOurLocalDevice() &&
!c.isBlocked() &&
c.get('secondaryStatus')
);
// then morph all secondary conversation to their primary
sessionContactsSecondary =
(await Promise.all(
// eslint-disable-next-line arrow-body-style
sessionContactsSecondary.map(async c => {
return window.ConversationController.getOrCreateAndWait(
c.getPrimaryDevicePubKey(),
'private'
);
})
)) || [];
// filter out our primary pubkey if it was added.
sessionContactsSecondary = sessionContactsSecondary.filter(
c => c.id !== primaryDeviceKey
);
const contactsSet = new Set([
...sessionContactsPrimary,
...sessionContactsSecondary,
]);
if (contactsSet.size === 0) {
window.console.info('No contacts to sync.');
return Promise.resolve();
}
libloki.api.debug.logContactSync('Triggering contact sync message with:', [
...contactsSet,
]);
// We need to sync across 3 contacts at a time
// This is to avoid hitting storage server limit
const chunked = _.chunk([...contactsSet], 3);
const syncMessages = await Promise.all(
chunked.map(c => libloki.api.createContactSyncProtoMessage(c))
);
const syncPromises = syncMessages
.filter(message => message != null)
.map(syncMessage => {
const contentMessage = new textsecure.protobuf.Content();
contentMessage.syncMessage = syncMessage;
const silent = true;
const debugMessageType =
window.textsecure.OutgoingMessage.DebugMessageType.CONTACT_SYNC_SEND;
return this.sendIndividualProto(
primaryDeviceKey,
contentMessage,
Date.now(),
silent,
{ debugMessageType } // options
);
});
return Promise.all(syncPromises); // // If we havn't got a primaryDeviceKey then we are in the middle of pairing
// // primaryDevicePubKey is set to our own number if we are the master device
// const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
// if (!primaryDeviceKey) {
// return Promise.resolve();
// }
// // first get all friends with primary devices
// const sessionContactsPrimary =
// conversations.filter(
// c =>
// c.isPrivate() &&
// !c.isOurLocalDevice() &&
// !c.isBlocked() &&
// !c.get('secondaryStatus')
// ) || [];
// // then get all friends with secondary devices
// let sessionContactsSecondary = conversations.filter(
// c =>
// c.isPrivate() &&
// !c.isOurLocalDevice() &&
// !c.isBlocked() &&
// c.get('secondaryStatus')
// );
// // then morph all secondary conversation to their primary
// sessionContactsSecondary =
// (await Promise.all(
// // eslint-disable-next-line arrow-body-style
// sessionContactsSecondary.map(async c => {
// return window.ConversationController.getOrCreateAndWait(
// c.getPrimaryDevicePubKey(),
// 'private'
// );
// })
// )) || [];
// // filter out our primary pubkey if it was added.
// sessionContactsSecondary = sessionContactsSecondary.filter(
// c => c.id !== primaryDeviceKey
// );
// const contactsSet = new Set([
// ...sessionContactsPrimary,
// ...sessionContactsSecondary,
// ]);
// if (contactsSet.size === 0) {
// window.console.info('No contacts to sync.');
// return Promise.resolve();
// }
// libloki.api.debug.logContactSync('Triggering contact sync message with:', [
// ...contactsSet,
// ]);
// // We need to sync across 3 contacts at a time
// // This is to avoid hitting storage server limit
// const chunked = _.chunk([...contactsSet], 3);
// const syncMessages = await Promise.all(
// chunked.map(c => libloki.api.createContactSyncProtoMessage(c))
// );
// const syncPromises = syncMessages
// .filter(message => message != null)
// .map(syncMessage => {
// const contentMessage = new textsecure.protobuf.Content();
// contentMessage.syncMessage = syncMessage;
// const silent = true;
// const debugMessageType =
// window.textsecure.OutgoingMessage.DebugMessageType.CONTACT_SYNC_SEND;
// return this.sendIndividualProto(
// primaryDeviceKey,
// contentMessage,
// Date.now(),
// silent,
// { debugMessageType } // options
// );
// });
// return Promise.all(syncPromises);
}, },
sendGroupSyncMessage(conversations) { sendGroupSyncMessage(conversations) {
// If we havn't got a primaryDeviceKey then we are in the middle of pairing return Promise.resolve();
// primaryDevicePubKey is set to our own number if we are the master device // // If we havn't got a primaryDeviceKey then we are in the middle of pairing
const primaryDeviceKey = window.storage.get('primaryDevicePubKey'); // // primaryDevicePubKey is set to our own number if we are the master device
if (!primaryDeviceKey) { // const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
window.console.debug('sendGroupSyncMessage: no primary device pubkey'); // if (!primaryDeviceKey) {
return Promise.resolve(); // window.console.debug('sendGroupSyncMessage: no primary device pubkey');
} // return Promise.resolve();
// We only want to sync across closed groups that we haven't left // }
const sessionGroups = conversations.filter( // // We only want to sync across closed groups that we haven't left
c => // const sessionGroups = conversations.filter(
c.isClosedGroup() && // c =>
!c.get('left') && // c.isClosedGroup() &&
!c.isBlocked() && // !c.get('left') &&
!c.isMediumGroup() // !c.isBlocked() &&
); // !c.isMediumGroup()
if (sessionGroups.length === 0) { // );
window.console.info('No closed group to sync.'); // if (sessionGroups.length === 0) {
return Promise.resolve(); // window.console.info('No closed group to sync.');
} // return Promise.resolve();
// }
// We need to sync across 1 group at a time
// This is because we could hit the storage server limit with one group // // We need to sync across 1 group at a time
const syncPromises = sessionGroups // // This is because we could hit the storage server limit with one group
.map(c => libloki.api.createGroupSyncProtoMessage(c)) // const syncPromises = sessionGroups
.filter(message => message != null) // .map(c => libloki.api.createGroupSyncProtoMessage(c))
.map(syncMessage => { // .filter(message => message != null)
const contentMessage = new textsecure.protobuf.Content(); // .map(syncMessage => {
contentMessage.syncMessage = syncMessage; // const contentMessage = new textsecure.protobuf.Content();
// contentMessage.syncMessage = syncMessage;
const silent = true;
const debugMessageType = // const silent = true;
window.textsecure.OutgoingMessage.DebugMessageType // const debugMessageType =
.CLOSED_GROUP_SYNC_SEND; // window.textsecure.OutgoingMessage.DebugMessageType
// .CLOSED_GROUP_SYNC_SEND;
return this.sendIndividualProto(
primaryDeviceKey, // return this.sendIndividualProto(
contentMessage, // primaryDeviceKey,
Date.now(), // contentMessage,
silent, // Date.now(),
{ debugMessageType } // options // silent,
); // { debugMessageType } // options
}); // );
// });
return Promise.all(syncPromises);
// return Promise.all(syncPromises);
}, },
sendOpenGroupsSyncMessage(conversations) { sendOpenGroupsSyncMessage(conversations) {

@ -53,7 +53,7 @@ export class GroupNotification extends React.Component<Props> {
return `${i18n('titleIsNow', [newName || ''])}.`; return `${i18n('titleIsNow', [newName || ''])}.`;
case 'add': case 'add':
if (!contacts || !contacts.length) { if (!contacts || !contacts.length) {
throw new Error('Group update is missing contacts'); throw new Error('Group update add is missing contacts');
} }
const joinKey = const joinKey =
@ -66,7 +66,7 @@ export class GroupNotification extends React.Component<Props> {
} }
if (!contacts || !contacts.length) { if (!contacts || !contacts.length) {
throw new Error('Group update is missing contacts'); throw new Error('Group update remove is missing contacts');
} }
const leftKey = const leftKey =
@ -79,7 +79,9 @@ export class GroupNotification extends React.Component<Props> {
} }
if (!contacts || !contacts.length) { if (!contacts || !contacts.length) {
throw new Error('Group update is missing contacts'); // FIXME audric
return 'FIXME audric';
// throw new Error('Group update kicked is missing contacts');
} }
const kickedKey = const kickedKey =

@ -176,13 +176,13 @@ enum ConversationType {
} }
async function sendDeliveryReceipt(source: string, timestamp: any) { async function sendDeliveryReceipt(source: string, timestamp: any) {
const receiptMessage = new DeliveryReceiptMessage({ // const receiptMessage = new DeliveryReceiptMessage({
timestamp: Date.now(), // timestamp: Date.now(),
timestamps: [timestamp], // timestamps: [timestamp],
}); // });
const device = new PubKey(source); // const device = new PubKey(source);
await getMessageQueue().sendUsingMultiDevice(device, receiptMessage); // await getMessageQueue().sendUsingMultiDevice(device, receiptMessage);
} }
interface MessageId { interface MessageId {

@ -150,6 +150,8 @@ export class ChatMessage extends DataMessage {
}); });
} }
dataMessage.timestamp = this.timestamp;
return dataMessage; return dataMessage;
} }

Loading…
Cancel
Save