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 => {
return contact.isVerified(); // if (contact.isMe()) {
}); // 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); // const device = new libsession.Types.PubKey(sender);
await libsession // await libsession
.getMessageQueue() // .getMessageQueue()
.sendUsingMultiDevice(device, receiptMessage); // .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
// primaryDevicePubKey is set to our own number if we are the master device
const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
if (!primaryDeviceKey) {
return Promise.resolve(); 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(); // // 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
libloki.api.debug.logContactSync('Triggering contact sync message with:', [ // const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
...contactsSet, // if (!primaryDeviceKey) {
]); // return Promise.resolve();
// }
// We need to sync across 3 contacts at a time // // first get all friends with primary devices
// This is to avoid hitting storage server limit // const sessionContactsPrimary =
const chunked = _.chunk([...contactsSet], 3); // conversations.filter(
const syncMessages = await Promise.all( // c =>
chunked.map(c => libloki.api.createContactSyncProtoMessage(c)) // c.isPrivate() &&
); // !c.isOurLocalDevice() &&
const syncPromises = syncMessages // !c.isBlocked() &&
.filter(message => message != null) // !c.get('secondaryStatus')
.map(syncMessage => { // ) || [];
const contentMessage = new textsecure.protobuf.Content();
contentMessage.syncMessage = syncMessage; // // then get all friends with secondary devices
// let sessionContactsSecondary = conversations.filter(
const silent = true; // c =>
// c.isPrivate() &&
const debugMessageType = // !c.isOurLocalDevice() &&
window.textsecure.OutgoingMessage.DebugMessageType.CONTACT_SYNC_SEND; // !c.isBlocked() &&
// c.get('secondaryStatus')
return this.sendIndividualProto( // );
primaryDeviceKey,
contentMessage, // // then morph all secondary conversation to their primary
Date.now(), // sessionContactsSecondary =
silent, // (await Promise.all(
{ debugMessageType } // options // // eslint-disable-next-line arrow-body-style
); // sessionContactsSecondary.map(async c => {
}); // return window.ConversationController.getOrCreateAndWait(
// c.getPrimaryDevicePubKey(),
return Promise.all(syncPromises); // '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
// primaryDevicePubKey is set to our own number if we are the master device
const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
if (!primaryDeviceKey) {
window.console.debug('sendGroupSyncMessage: no primary device pubkey');
return Promise.resolve(); return Promise.resolve();
} // // If we havn't got a primaryDeviceKey then we are in the middle of pairing
// We only want to sync across closed groups that we haven't left // // primaryDevicePubKey is set to our own number if we are the master device
const sessionGroups = conversations.filter( // const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
c => // if (!primaryDeviceKey) {
c.isClosedGroup() && // window.console.debug('sendGroupSyncMessage: no primary device pubkey');
!c.get('left') && // return Promise.resolve();
!c.isBlocked() && // }
!c.isMediumGroup() // // We only want to sync across closed groups that we haven't left
); // const sessionGroups = conversations.filter(
if (sessionGroups.length === 0) { // c =>
window.console.info('No closed group to sync.'); // c.isClosedGroup() &&
return Promise.resolve(); // !c.get('left') &&
} // !c.isBlocked() &&
// !c.isMediumGroup()
// We need to sync across 1 group at a time // );
// This is because we could hit the storage server limit with one group // if (sessionGroups.length === 0) {
const syncPromises = sessionGroups // window.console.info('No closed group to sync.');
.map(c => libloki.api.createGroupSyncProtoMessage(c)) // return Promise.resolve();
.filter(message => message != null) // }
.map(syncMessage => {
const contentMessage = new textsecure.protobuf.Content(); // // We need to sync across 1 group at a time
contentMessage.syncMessage = syncMessage; // // This is because we could hit the storage server limit with one group
// const syncPromises = sessionGroups
const silent = true; // .map(c => libloki.api.createGroupSyncProtoMessage(c))
const debugMessageType = // .filter(message => message != null)
window.textsecure.OutgoingMessage.DebugMessageType // .map(syncMessage => {
.CLOSED_GROUP_SYNC_SEND; // const contentMessage = new textsecure.protobuf.Content();
// contentMessage.syncMessage = syncMessage;
return this.sendIndividualProto(
primaryDeviceKey, // const silent = true;
contentMessage, // const debugMessageType =
Date.now(), // window.textsecure.OutgoingMessage.DebugMessageType
silent, // .CLOSED_GROUP_SYNC_SEND;
{ debugMessageType } // options
); // return this.sendIndividualProto(
}); // primaryDeviceKey,
// contentMessage,
return Promise.all(syncPromises); // Date.now(),
// silent,
// { debugMessageType } // options
// );
// });
// 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