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

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

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

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

@ -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 */ /* eslint-disable more/no-then, no-bitwise */
@ -792,8 +792,6 @@ MessageSender.prototype = {
return Promise.resolve(); return Promise.resolve();
}, },
sendDeliveryReceipt(recipientId, timestamp, options) { sendDeliveryReceipt(recipientId, timestamp, options) {
const myNumber = textsecure.storage.user.getNumber(); const myNumber = textsecure.storage.user.getNumber();
const myDevice = textsecure.storage.user.getDeviceId(); const myDevice = textsecure.storage.user.getDeviceId();

@ -40,7 +40,9 @@ export class TypingMessage extends ContentMessage {
const typingMessage = new SignalService.TypingMessage(); const typingMessage = new SignalService.TypingMessage();
if (this.groupId) { 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.action = action;
typingMessage.timestamp = finalTimestamp; typingMessage.timestamp = finalTimestamp;

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

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

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

Loading…
Cancel
Save