Merge remote-tracking branch 'upstream/clearnet' into hooking-up-sending

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

@ -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 => {

@ -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() {

@ -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

@ -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);
}

@ -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;
}

@ -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 });

@ -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) {

@ -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<Array<PrimaryPubKey>> {
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;

@ -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<void>>;

Loading…
Cancel
Save