This commit is contained in:
Audric Ackermann 2020-06-19 11:41:19 +10:00
parent a351ef86dd
commit 439ea09027
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
8 changed files with 30 additions and 24 deletions

View file

@ -407,15 +407,23 @@
typingTimestamp: Date.now(),
groupId, // might be null
};
const typingMessage = new libsession.Messages.Outgoing.TypingMessage(typingParams);
const typingMessage = new libsession.Messages.Outgoing.TypingMessage(
typingParams
);
// send the message to a single recipient if this is a session chat
if (this.isPrivate) {
const device = new libsession.Types.PubKey(recipientId);
libsession.getMessageQueue().sendUsingMultiDevice(device, typingMessage).ignore();
libsession
.getMessageQueue()
.sendUsingMultiDevice(device, typingMessage)
.ignore();
} else {
// the recipients on the case of a group are found by the messageQueue using message.groupId
libsession.getMessageQueue().sendToGroup(typingMessage).ignore();
libsession
.getMessageQueue()
.sendToGroup(typingMessage)
.ignore();
}
},
@ -1850,7 +1858,6 @@
);
message.set({ id: messageId });
if (groupUpdate.is_medium_group) {
// Constructing a "create group" message
const proto = new textsecure.protobuf.DataMessage();
@ -2040,16 +2047,11 @@
);
if (storage.get('read-receipt-setting')) {
await Promise.all(
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
const timestamps = _.map(receipts, 'timestamp');
await this.wrapSend(
textsecure.messaging.sendReadReceipts(
sender,
timestamps,
{}
)
textsecure.messaging.sendReadReceipts(sender, timestamps, {})
);
})
);

View file

@ -1172,12 +1172,9 @@ MessageReceiver.prototype.extend({
if (envelope.type === SESSION_REQUEST) {
await this.handleSessionRequestMessage(envelope, content);
} else {
const device = new libsession.Types.PubKey(envelope.source);
await libsession.Protocols.SessionProtocol.onSessionEstablished(
device
);
await libsession.Protocols.SessionProtocol.onSessionEstablished(device);
// TODO process sending queue for this device now that we have a session
}

View file

@ -213,7 +213,9 @@ OutgoingMessage.prototype = {
}
return (
window.libsession.Protocols.MultiDeviceProtocol.getAllDevices(primaryPubKey)
window.libsession.Protocols.MultiDeviceProtocol.getAllDevices(
primaryPubKey
)
// Don't send to ourselves
.then(devicesPubKeys =>
devicesPubKeys.filter(pubKey => pubKey !== ourNumber)

View file

@ -1,4 +1,4 @@
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window, libloki, libsession */
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window, libloki */
/* eslint-disable more/no-then, no-bitwise */
@ -792,8 +792,6 @@ MessageSender.prototype = {
return Promise.resolve();
},
sendDeliveryReceipt(recipientId, timestamp, options) {
const myNumber = textsecure.storage.user.getNumber();
const myDevice = textsecure.storage.user.getDeviceId();

View file

@ -40,7 +40,9 @@ export class TypingMessage extends ContentMessage {
const typingMessage = new SignalService.TypingMessage();
if (this.groupId) {
typingMessage.groupId = new Uint8Array(StringUtils.encode(this.groupId, 'binary'));
typingMessage.groupId = new Uint8Array(
StringUtils.encode(this.groupId, 'binary')
);
}
typingMessage.action = action;
typingMessage.timestamp = finalTimestamp;

View file

@ -181,7 +181,9 @@ export class SessionProtocol {
const processedItem = await getItemById('processedSessionsTimestamp');
if (processedItem) {
SessionProtocol.processedSessionsTimestamp = JSON.parse(processedItem.value);
SessionProtocol.processedSessionsTimestamp = JSON.parse(
processedItem.value
);
} else {
SessionProtocol.processedSessionsTimestamp = {};
}

View file

@ -51,7 +51,7 @@ export class MessageQueue implements MessageQueueInterface {
let currentDevices = [...devices];
// Sync to our devices if syncable
if (await SyncMessageUtils.canSync(message)) {
if (SyncMessageUtils.canSync(message)) {
const currentDevice = await UserUtil.getCurrentDevicePubKey();
if (currentDevice) {
@ -91,7 +91,11 @@ export class MessageQueue implements MessageQueueInterface {
const recipients = await GroupUtils.getGroupMembers(groupPubKey);
if (recipients.length) {
await Promise.all(recipients.map(async recipient => this.sendUsingMultiDevice(recipient, message)));
await Promise.all(
recipients.map(async recipient =>
this.sendUsingMultiDevice(recipient, message)
)
);
return true;
}
@ -159,7 +163,6 @@ export class MessageQueue implements MessageQueueInterface {
}
private async processAllPending() {
const devices = this.pendingMessageCache.getDevices();
const promises = devices.map(async device => this.processPending(device));

View file

@ -13,7 +13,7 @@ import { TextEncoder } from 'util';
describe('toRawMessage', () => {
let message: DeviceUnlinkMessage;
const pubkey: PubKey = TestUtils.generateFakePubkey();
const pubkey: PubKey = TestUtils.generateFakePubKey();
let raw: RawMessage;
beforeEach(() => {