This commit is contained in:
Maxim Shishmarev 2020-07-02 12:47:31 +10:00
parent 255c7ada68
commit b31b6bb912
4 changed files with 19 additions and 33 deletions

View file

@ -1,6 +1,6 @@
/* global Whisper, Signal, setTimeout, clearTimeout, MessageController, NewReceiver */
const { isFunction, isNumber, omit } = require('lodash');
const { isNumber, omit } = require('lodash');
const getGuid = require('uuid/v4');
const {
getMessageById,

View file

@ -301,9 +301,7 @@ async function handleDecryptedEnvelope(
}
}
export async function handleUnencryptedMessage({message : outerMessage} : any) {
export async function handleUnencryptedMessage({ message: outerMessage }: any) {
const { source } = outerMessage;
const { group, profile, profileKey } = outerMessage.message;
@ -315,27 +313,20 @@ export async function handleUnencryptedMessage({message : outerMessage} : any) {
source,
'private'
);
await updateProfile(
conversation,
profile,
profileKey
);
await updateProfile(conversation, profile, profileKey);
}
const primaryDevice = window.storage.get('primaryDevicePubKey');
const isOurDevice = source &&
(source === ourNumber || source === primaryDevice);
const isOurDevice =
source && (source === ourNumber || source === primaryDevice);
const isPublicChatMessage =
group &&
group.id &&
!!group.id.match(/^publicChat:/);
group && group.id && !!group.id.match(/^publicChat:/);
const ev = {
// Public chat messages from ourselves should be outgoing
type: (isPublicChatMessage && isOurDevice) ? 'sent' : 'message',
type: isPublicChatMessage && isOurDevice ? 'sent' : 'message',
data: outerMessage,
};
await handleMessageEvent(ev);
}

View file

@ -164,7 +164,6 @@ export class SwarmPolling {
node: Snode,
pubkey: PubKey
): Promise<Array<any>> {
const edkey = node.pubkey_ed25519;
const pkStr = pubkey.key ? pubkey.key : pubkey;

View file

@ -21,22 +21,18 @@ describe('Sync Message Utils', () => {
// Fill half with secondaries, half with primaries
const numConversations = 20;
const primaryConversations = new Array(numConversations / 2)
.fill({})
.map(
() =>
new TestUtils.MockConversation({
type: TestUtils.MockConversationType.Primary,
})
);
const secondaryConversations = new Array(numConversations / 2)
.fill({})
.map(
() =>
new TestUtils.MockConversation({
type: TestUtils.MockConversationType.Secondary,
})
);
const primaryConversations = new Array(numConversations / 2).fill({}).map(
() =>
new TestUtils.MockConversation({
type: TestUtils.MockConversationType.Primary,
})
);
const secondaryConversations = new Array(numConversations / 2).fill({}).map(
() =>
new TestUtils.MockConversation({
type: TestUtils.MockConversationType.Secondary,
})
);
const conversations = [...primaryConversations, ...secondaryConversations];
const sandbox = sinon.createSandbox();