diff --git a/js/models/conversations.js b/js/models/conversations.js index 65a7b4af8..b4d4f0794 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -723,7 +723,7 @@ if (!this.contactCollection.length) { return false; } - console.log('this.contactCollection', this.contactCollection) + // console.log('this.contactCollection', this.contactCollection); //FIXME AUDRIC return true; // return this.contactCollection.every(contact => { diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index a644f1038..f4af66706 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -488,10 +488,9 @@ class LokiSnodeAPI { async buildNewOnionPaths() { // this function may be called concurrently make sure we only have one inflight - return primitives.allowOnlyOneAtATime( - 'buildNewOnionPaths', - () => this.buildNewOnionPathsWorker() - ); + return primitives.allowOnlyOneAtATime('buildNewOnionPaths', async () => { + await this.buildNewOnionPathsWorker(); + }); } async getRandomSnodeAddress() { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index d1aa81d55..7b31fbfb3 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -389,7 +389,6 @@ MessageSender.prototype = { silent, options = {} ) { - // Note: Since we're just doing independant tasks, // using `async` in the `forEach` loop should be fine. // If however we want to use the results from forEach then diff --git a/ts/receiver/receiver.ts b/ts/receiver/receiver.ts index c7b94bc36..ad8a9a9b2 100644 --- a/ts/receiver/receiver.ts +++ b/ts/receiver/receiver.ts @@ -180,7 +180,6 @@ async function sendDeliveryReceipt(source: string, timestamp: any) { // timestamp: Date.now(), // timestamps: [timestamp], // }); - // const device = new PubKey(source); // await getMessageQueue().sendUsingMultiDevice(device, receiptMessage); } diff --git a/ts/session/messages/outgoing/content/data/group/ClosedGroupChatMessage.ts b/ts/session/messages/outgoing/content/data/group/ClosedGroupChatMessage.ts index fc7d4250f..a0f75f4b0 100644 --- a/ts/session/messages/outgoing/content/data/group/ClosedGroupChatMessage.ts +++ b/ts/session/messages/outgoing/content/data/group/ClosedGroupChatMessage.ts @@ -1,10 +1,11 @@ import { SignalService } from '../../../../../../protobuf'; import { ChatMessage } from '../ChatMessage'; import { ClosedGroupMessage } from './ClosedGroupMessage'; +import { PubKey } from '../../../../../types'; interface ClosedGroupChatMessageParams { identifier?: string; - groupId: string; + groupId: string | PubKey; chatMessage: ChatMessage; } diff --git a/ts/session/messages/outgoing/content/data/group/ClosedGroupMessage.ts b/ts/session/messages/outgoing/content/data/group/ClosedGroupMessage.ts index 0b07764a7..5fe9b561c 100644 --- a/ts/session/messages/outgoing/content/data/group/ClosedGroupMessage.ts +++ b/ts/session/messages/outgoing/content/data/group/ClosedGroupMessage.ts @@ -1,21 +1,23 @@ import { DataMessage } from '../DataMessage'; import { SignalService } from '../../../../../../protobuf'; import { MessageParams } from '../../../Message'; +import { PubKey } from '../../../../../types'; import { StringUtils } from '../../../../../utils'; export interface ClosedGroupMessageParams extends MessageParams { - groupId: string; + groupId: string | PubKey; } export abstract class ClosedGroupMessage extends DataMessage { - public readonly groupId: string; + public readonly groupId: PubKey; constructor(params: ClosedGroupMessageParams) { super({ timestamp: params.timestamp, identifier: params.identifier, }); - this.groupId = params.groupId; + const { groupId } = params; + this.groupId = typeof groupId === 'string' ? new PubKey(groupId) : groupId; } public ttl(): number { @@ -25,7 +27,7 @@ export abstract class ClosedGroupMessage extends DataMessage { protected abstract groupContextType(): SignalService.GroupContext.Type; protected groupContext(): SignalService.GroupContext { - const id = new Uint8Array(StringUtils.encode(this.groupId, 'utf8')); + const id = new Uint8Array(StringUtils.encode(this.groupId.key, 'utf8')); const type = this.groupContextType(); return new SignalService.GroupContext({ id, type }); diff --git a/ts/session/sending/MessageQueue.ts b/ts/session/sending/MessageQueue.ts index c3e30465b..60e812104 100644 --- a/ts/session/sending/MessageQueue.ts +++ b/ts/session/sending/MessageQueue.ts @@ -139,7 +139,7 @@ export class MessageQueue implements MessageQueueInterface { public async processPending(device: PubKey) { const messages = await this.pendingMessageCache.getForDevice(device); - const isMediumGroup = GroupUtils.isMediumGroup(device.key); + const isMediumGroup = GroupUtils.isMediumGroup(device); const hasSession = await SessionProtocol.hasSession(device); if (!isMediumGroup && !hasSession) { diff --git a/ts/session/utils/Groups.ts b/ts/session/utils/Groups.ts index c3c4cf1b9..adce15790 100644 --- a/ts/session/utils/Groups.ts +++ b/ts/session/utils/Groups.ts @@ -1,11 +1,11 @@ import _ from 'lodash'; -import { PrimaryPubKey } from '../types'; +import { PrimaryPubKey, PubKey } from '../types'; import { MultiDeviceProtocol } from '../protocols'; export async function getGroupMembers( - groupId: string + groupId: PubKey ): Promise> { - const groupConversation = window.ConversationController.get(groupId); + const groupConversation = window.ConversationController.get(groupId.key); const groupMembers = groupConversation ? groupConversation.attributes.members : undefined; @@ -22,8 +22,8 @@ export async function getGroupMembers( return _.uniqWith(primaryDevices, (a, b) => a.isEqual(b)); } -export function isMediumGroup(groupId: string): boolean { - const conversation = window.ConversationController.get(groupId); +export function isMediumGroup(groupId: PubKey): boolean { + const conversation = window.ConversationController.get(groupId.key); if (!conversation) { return false; diff --git a/ts/test/session/sending/MessageQueue_test.ts b/ts/test/session/sending/MessageQueue_test.ts index c0d223ffc..7d3bf5fc3 100644 --- a/ts/test/session/sending/MessageQueue_test.ts +++ b/ts/test/session/sending/MessageQueue_test.ts @@ -43,7 +43,7 @@ describe('MessageQueue', () => { // Message Sender Stubs let sendStub: sinon.SinonStub<[RawMessage, (number | undefined)?]>; // Utils Stubs - let isMediumGroupStub: sinon.SinonStub<[string], boolean>; + let isMediumGroupStub: sinon.SinonStub<[PubKey], boolean>; // Session Protocol Stubs let hasSessionStub: sinon.SinonStub<[PubKey]>; let sendSessionRequestIfNeededStub: sinon.SinonStub<[PubKey], Promise>;