pull/1204/head
Maxim Shishmarev 5 years ago
parent 255c7ada68
commit b31b6bb912

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

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

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

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

Loading…
Cancel
Save