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) { if (!this.contactCollection.length) {
return false; return false;
} }
console.log('this.contactCollection', this.contactCollection) // console.log('this.contactCollection', this.contactCollection);
//FIXME AUDRIC //FIXME AUDRIC
return true; return true;
// return this.contactCollection.every(contact => { // return this.contactCollection.every(contact => {

@ -488,10 +488,9 @@ class LokiSnodeAPI {
async buildNewOnionPaths() { async buildNewOnionPaths() {
// 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', async () => {
'buildNewOnionPaths', await this.buildNewOnionPathsWorker();
() => this.buildNewOnionPathsWorker() });
);
} }
async getRandomSnodeAddress() { async getRandomSnodeAddress() {

@ -389,7 +389,6 @@ MessageSender.prototype = {
silent, silent,
options = {} options = {}
) { ) {
// 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.
// If however we want to use the results from forEach then // 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(), // 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);
} }

@ -1,10 +1,11 @@
import { SignalService } from '../../../../../../protobuf'; import { SignalService } from '../../../../../../protobuf';
import { ChatMessage } from '../ChatMessage'; import { ChatMessage } from '../ChatMessage';
import { ClosedGroupMessage } from './ClosedGroupMessage'; import { ClosedGroupMessage } from './ClosedGroupMessage';
import { PubKey } from '../../../../../types';
interface ClosedGroupChatMessageParams { interface ClosedGroupChatMessageParams {
identifier?: string; identifier?: string;
groupId: string; groupId: string | PubKey;
chatMessage: ChatMessage; chatMessage: ChatMessage;
} }

@ -1,21 +1,23 @@
import { DataMessage } from '../DataMessage'; import { DataMessage } from '../DataMessage';
import { SignalService } from '../../../../../../protobuf'; import { SignalService } from '../../../../../../protobuf';
import { MessageParams } from '../../../Message'; import { MessageParams } from '../../../Message';
import { PubKey } from '../../../../../types';
import { StringUtils } from '../../../../../utils'; import { StringUtils } from '../../../../../utils';
export interface ClosedGroupMessageParams extends MessageParams { export interface ClosedGroupMessageParams extends MessageParams {
groupId: string; groupId: string | PubKey;
} }
export abstract class ClosedGroupMessage extends DataMessage { export abstract class ClosedGroupMessage extends DataMessage {
public readonly groupId: string; public readonly groupId: PubKey;
constructor(params: ClosedGroupMessageParams) { constructor(params: ClosedGroupMessageParams) {
super({ super({
timestamp: params.timestamp, timestamp: params.timestamp,
identifier: params.identifier, identifier: params.identifier,
}); });
this.groupId = params.groupId; const { groupId } = params;
this.groupId = typeof groupId === 'string' ? new PubKey(groupId) : groupId;
} }
public ttl(): number { public ttl(): number {
@ -25,7 +27,7 @@ export abstract class ClosedGroupMessage extends DataMessage {
protected abstract groupContextType(): SignalService.GroupContext.Type; protected abstract groupContextType(): SignalService.GroupContext.Type;
protected groupContext(): SignalService.GroupContext { 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(); const type = this.groupContextType();
return new SignalService.GroupContext({ id, type }); return new SignalService.GroupContext({ id, type });

@ -139,7 +139,7 @@ export class MessageQueue implements MessageQueueInterface {
public async processPending(device: PubKey) { public async processPending(device: PubKey) {
const messages = await this.pendingMessageCache.getForDevice(device); const messages = await this.pendingMessageCache.getForDevice(device);
const isMediumGroup = GroupUtils.isMediumGroup(device.key); const isMediumGroup = GroupUtils.isMediumGroup(device);
const hasSession = await SessionProtocol.hasSession(device); const hasSession = await SessionProtocol.hasSession(device);
if (!isMediumGroup && !hasSession) { if (!isMediumGroup && !hasSession) {

@ -1,11 +1,11 @@
import _ from 'lodash'; import _ from 'lodash';
import { PrimaryPubKey } from '../types'; import { PrimaryPubKey, PubKey } from '../types';
import { MultiDeviceProtocol } from '../protocols'; import { MultiDeviceProtocol } from '../protocols';
export async function getGroupMembers( export async function getGroupMembers(
groupId: string groupId: PubKey
): Promise<Array<PrimaryPubKey>> { ): Promise<Array<PrimaryPubKey>> {
const groupConversation = window.ConversationController.get(groupId); const groupConversation = window.ConversationController.get(groupId.key);
const groupMembers = groupConversation const groupMembers = groupConversation
? groupConversation.attributes.members ? groupConversation.attributes.members
: undefined; : undefined;
@ -22,8 +22,8 @@ export async function getGroupMembers(
return _.uniqWith(primaryDevices, (a, b) => a.isEqual(b)); return _.uniqWith(primaryDevices, (a, b) => a.isEqual(b));
} }
export function isMediumGroup(groupId: string): boolean { export function isMediumGroup(groupId: PubKey): boolean {
const conversation = window.ConversationController.get(groupId); const conversation = window.ConversationController.get(groupId.key);
if (!conversation) { if (!conversation) {
return false; return false;

@ -43,7 +43,7 @@ describe('MessageQueue', () => {
// Message Sender Stubs // Message Sender Stubs
let sendStub: sinon.SinonStub<[RawMessage, (number | undefined)?]>; let sendStub: sinon.SinonStub<[RawMessage, (number | undefined)?]>;
// Utils Stubs // Utils Stubs
let isMediumGroupStub: sinon.SinonStub<[string], boolean>; let isMediumGroupStub: sinon.SinonStub<[PubKey], boolean>;
// Session Protocol Stubs // Session Protocol Stubs
let hasSessionStub: sinon.SinonStub<[PubKey]>; let hasSessionStub: sinon.SinonStub<[PubKey]>;
let sendSessionRequestIfNeededStub: sinon.SinonStub<[PubKey], Promise<void>>; let sendSessionRequestIfNeededStub: sinon.SinonStub<[PubKey], Promise<void>>;

Loading…
Cancel
Save