From 598d6d1010de41885e45cccb1a265b712983e80c Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 15 Jul 2020 14:32:05 +1000 Subject: [PATCH 01/17] drop auto fr messages 'Please Accept... ' --- ts/receiver/dataMessage.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index c371e6778..12e12419b 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -251,7 +251,10 @@ function isMessageEmpty(message: SignalService.DataMessage) { return ( !flags && - _.isEmpty(body) && + // FIXME remove this hack to drop auto friend requests messages in a few weeks 15/07/2020 + (_.isEmpty(body) || + body === + 'Please accept to enable messages to be synced across devices') && _.isEmpty(attachments) && _.isEmpty(group) && _.isEmpty(quote) && From 17cae3937dc885459084224f3cee0e6b86ddc30b Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 15 Jul 2020 16:30:47 +1000 Subject: [PATCH 02/17] drop synced message with the autoFR content --- ts/receiver/dataMessage.ts | 14 +++++++++++--- ts/receiver/syncMessages.ts | 11 ++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 12e12419b..7651951f4 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -252,9 +252,7 @@ function isMessageEmpty(message: SignalService.DataMessage) { return ( !flags && // FIXME remove this hack to drop auto friend requests messages in a few weeks 15/07/2020 - (_.isEmpty(body) || - body === - 'Please accept to enable messages to be synced across devices') && + isBodyEmpty(body) && _.isEmpty(attachments) && _.isEmpty(group) && _.isEmpty(quote) && @@ -265,6 +263,16 @@ function isMessageEmpty(message: SignalService.DataMessage) { ); } +function isBodyEmpty(body: string) { + return _.isEmpty(body) || isBodyAutoFRContent(body); +} + +export function isBodyAutoFRContent(body: string) { + return ( + body === 'Please accept to enable messages to be synced across devices' + ); +} + export async function handleDataMessage( envelope: EnvelopePlus, dataMessage: SignalService.IDataMessage diff --git a/ts/receiver/syncMessages.ts b/ts/receiver/syncMessages.ts index d4d574bc7..61bb16c41 100644 --- a/ts/receiver/syncMessages.ts +++ b/ts/receiver/syncMessages.ts @@ -7,7 +7,11 @@ import ByteBuffer from 'bytebuffer'; import { handleEndSession } from './sessionHandling'; import { handleMediumGroupUpdate } from './mediumGroups'; -import { handleMessageEvent, processDecrypted } from './dataMessage'; +import { + handleMessageEvent, + isBodyAutoFRContent, + processDecrypted, +} from './dataMessage'; import { updateProfile } from './receiver'; import { handleContacts } from './multidevice'; import { onGroupReceived } from './groups'; @@ -84,6 +88,11 @@ async function handleSentMessage( if (!msg) { window.log('Inner message is missing in a sync message'); + return; + } + + if (msg.body && isBodyAutoFRContent(msg.body)) { + window.console.log('dropping autoFR message synced'); await removeFromCache(envelope); return; } From 0c8e34a78e2de7536c891eb9bf4cca6531ea8467 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 16 Jul 2020 09:41:16 +1000 Subject: [PATCH 03/17] remove envelope from cache if sentMessage is empty --- ts/receiver/syncMessages.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ts/receiver/syncMessages.ts b/ts/receiver/syncMessages.ts index 61bb16c41..c4cf355f1 100644 --- a/ts/receiver/syncMessages.ts +++ b/ts/receiver/syncMessages.ts @@ -88,6 +88,7 @@ async function handleSentMessage( if (!msg) { window.log('Inner message is missing in a sync message'); + await removeFromCache(envelope); return; } From 9df0a79fb9832c6835177c78719bdf3a2b8fc6f8 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 16 Jul 2020 10:24:13 +1000 Subject: [PATCH 04/17] remove blockedNumber.js --- js/models/blockedNumbers.js | 83 ------------------------------------- ts/receiver/multidevice.ts | 7 ---- 2 files changed, 90 deletions(-) delete mode 100644 js/models/blockedNumbers.js diff --git a/js/models/blockedNumbers.js b/js/models/blockedNumbers.js deleted file mode 100644 index cb24c6466..000000000 --- a/js/models/blockedNumbers.js +++ /dev/null @@ -1,83 +0,0 @@ -/* global storage, _ */ -/* global _: false */ -/* global Backbone: false */ - -/* global BlockedNumberController: false */ -/* global storage: false */ -/* global Whisper: false */ - -/* eslint-disable more/no-then */ - -// eslint-disable-next-line func-names -(function() { - 'use strict'; - - window.Whisper = window.Whisper || {}; - - const BLOCKED_NUMBERS_ID = 'blocked'; - const BLOCKED_GROUPS_ID = 'blocked-groups'; - - storage.isBlocked = number => { - const numbers = storage.get(BLOCKED_NUMBERS_ID, []); - - return _.include(numbers, number); - }; - storage.getBlockedNumbers = () => storage.get(BLOCKED_NUMBERS_ID, []); - storage.addBlockedNumber = number => { - const numbers = storage.get(BLOCKED_NUMBERS_ID, []); - if (_.include(numbers, number)) { - return; - } - - window.log.info('adding', number, 'to blocked list'); - storage.put(BLOCKED_NUMBERS_ID, numbers.concat(number)); - }; - storage.removeBlockedNumber = number => { - const numbers = storage.get(BLOCKED_NUMBERS_ID, []); - if (!_.include(numbers, number)) { - return; - } - - window.log.info('removing', number, 'from blocked list'); - storage.put(BLOCKED_NUMBERS_ID, _.without(numbers, number)); - }; - - storage.isGroupBlocked = groupId => { - const groupIds = storage.get(BLOCKED_GROUPS_ID, []); - - return _.include(groupIds, groupId); - }; - storage.removeBlockedGroup = groupId => { - const groupIds = storage.get(BLOCKED_GROUPS_ID, []); - if (!_.include(groupIds, groupId)) { - return; - } - - window.log.info(`removing group(${groupId} from blocked list`); - storage.put(BLOCKED_GROUPS_ID, _.without(groupIds, groupId)); - }; - - Whisper.BlockedNumber = Backbone.Model.extend({ - defaults() { - return { - number: '', - }; - }, - block() { - return BlockedNumberController.block(this.number); - }, - unblock() { - return BlockedNumberController.unblock(this.number); - }, - }); - - Whisper.BlockedNumberCollection = Backbone.Collection.extend({ - model: Whisper.BlockedNumber, - comparator(m) { - return m.get('number'); - }, - getModel(number) { - return this.models.find(m => m.get('number') === number); - }, - }); -})(); diff --git a/ts/receiver/multidevice.ts b/ts/receiver/multidevice.ts index 9633c3247..eda7c3cba 100644 --- a/ts/receiver/multidevice.ts +++ b/ts/receiver/multidevice.ts @@ -366,13 +366,6 @@ async function onContactReceived(details: any) { conversation.setProfileKey(profileKey); } - if (details.blocked !== 'undefined') { - if (details.blocked) { - storage.addBlockedNumber(id); - } else { - storage.removeBlockedNumber(id); - } - } // Do not set name to allow working with lokiProfile and nicknames conversation.set({ From 3775a9ef050437d3ac98363337c834f273630889 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 16 Jul 2020 11:41:09 +1000 Subject: [PATCH 05/17] drop empty synced message (or autoFR) --- ts/receiver/dataMessage.ts | 4 ++-- ts/receiver/syncMessages.ts | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 7651951f4..24de0c604 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -236,7 +236,7 @@ export async function processDecrypted(envelope: EnvelopePlus, decrypted: any) { /* tslint:disable:no-bitwise */ } -function isMessageEmpty(message: SignalService.DataMessage) { +export function isMessageEmpty(message: SignalService.DataMessage) { const { flags, body, @@ -267,7 +267,7 @@ function isBodyEmpty(body: string) { return _.isEmpty(body) || isBodyAutoFRContent(body); } -export function isBodyAutoFRContent(body: string) { +function isBodyAutoFRContent(body: string) { return ( body === 'Please accept to enable messages to be synced across devices' ); diff --git a/ts/receiver/syncMessages.ts b/ts/receiver/syncMessages.ts index c4cf355f1..94b56e432 100644 --- a/ts/receiver/syncMessages.ts +++ b/ts/receiver/syncMessages.ts @@ -9,13 +9,14 @@ import { handleEndSession } from './sessionHandling'; import { handleMediumGroupUpdate } from './mediumGroups'; import { handleMessageEvent, - isBodyAutoFRContent, + isMessageEmpty, processDecrypted, } from './dataMessage'; import { updateProfile } from './receiver'; import { handleContacts } from './multidevice'; import { onGroupReceived } from './groups'; import { MultiDeviceProtocol } from '../session/protocols'; +import { DataMessage } from '../session/messages/outgoing'; export async function handleSyncMessage( envelope: EnvelopePlus, @@ -92,8 +93,8 @@ async function handleSentMessage( return; } - if (msg.body && isBodyAutoFRContent(msg.body)) { - window.console.log('dropping autoFR message synced'); + if (isMessageEmpty(msg as SignalService.DataMessage)) { + window.console.log('dropping empty message synced'); await removeFromCache(envelope); return; } From ba7241b2cb8fd5e9836ea775b8f2b8281a968447 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 16 Jul 2020 11:41:38 +1000 Subject: [PATCH 06/17] contactSync: mark conversation as secondary when they are --- ts/receiver/multidevice.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ts/receiver/multidevice.ts b/ts/receiver/multidevice.ts index eda7c3cba..e9e1187c3 100644 --- a/ts/receiver/multidevice.ts +++ b/ts/receiver/multidevice.ts @@ -340,10 +340,10 @@ async function onContactReceived(details: any) { } const ourPrimaryKey = window.storage.get('primaryDevicePubKey'); if (ourPrimaryKey) { - const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices( + const ourSecondaryDevices = await MultiDeviceProtocol.getSecondaryDevices( ourPrimaryKey ); - if (secondaryDevices.some(device => device.key === id)) { + if (ourSecondaryDevices.some(device => device.key === id)) { await conversation.setSecondaryStatus(true, ourPrimaryKey); } } @@ -354,6 +354,17 @@ async function onContactReceived(details: any) { ConversationController.getOrCreateAndWait(d.key, 'private') ) ); + const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices(id); + await Promise.all( + secondaryDevices.map(async d => { + const secondaryConv = await ConversationController.getOrCreateAndWait( + d.key, + 'private' + ); + await secondaryConv.setSecondaryStatus(true, id); + }) + ); + // triger session request with every devices of that user // when we do not have a session with it already deviceConversations.forEach(device => { From 9a5c73af3cc471e32f2486dbf4c4e4b314d09f2e Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 16 Jul 2020 11:41:59 +1000 Subject: [PATCH 07/17] do not update loki display name is given string is '' onContactSync --- ts/receiver/multidevice.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ts/receiver/multidevice.ts b/ts/receiver/multidevice.ts index e9e1187c3..7824882b4 100644 --- a/ts/receiver/multidevice.ts +++ b/ts/receiver/multidevice.ts @@ -377,16 +377,17 @@ async function onContactReceived(details: any) { conversation.setProfileKey(profileKey); } - // Do not set name to allow working with lokiProfile and nicknames conversation.set({ // name: details.name, color: details.color, }); - await conversation.setLokiProfile({ displayName: details.name }); + if (details.name && details.name.length) { + await conversation.setLokiProfile({ displayName: details.name }); + } - if (details.nickname) { + if (details.nickname && details.nickname.length) { await conversation.setNickname(details.nickname); } From 1cf90d95850479ff33ccaf65cf86c1dcefb59780 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Wed, 15 Jul 2020 19:48:35 -0700 Subject: [PATCH 08/17] better detect when token is no longer valid (helps whitelist servers) --- js/modules/loki_app_dot_net_api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index da97bfdb8..cc05254cc 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -1533,6 +1533,10 @@ class LokiPublicChannelAPI { }); if (res.err || !res.response || !res.response.data) { + if (res.statusCode === 403) { + // token is now invalid + this.serverAPI.getOrRefreshServerToken(true); + } return; } @@ -1656,6 +1660,10 @@ class LokiPublicChannelAPI { !res.response.data || !res.response.meta ) { + if (res.statusCode === 403) { + // token is now invalid + this.serverAPI.getOrRefreshServerToken(true); + } if (res.err) { log.error(`pollOnceForDeletions Error ${res.err}`); } else { @@ -1852,6 +1860,10 @@ class LokiPublicChannelAPI { }); if (res.err || !res.response) { + if (res.statusCode === 403) { + // token is now invalid + this.serverAPI.getOrRefreshServerToken(true); + } log.error( `app_dot_net:::pollOnceForMessages - Could not get messages from`, this.serverAPI.baseServerUrl, From 9e14615cd2383c5c48afcab3e9b9691f21501ddf Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 16 Jul 2020 13:30:38 +1000 Subject: [PATCH 09/17] Remove RSS Feeds --- app/sql.js | 41 +++++++--- js/background.js | 8 -- js/modules/data.js | 9 --- js/modules/loki_rss_api.js | 162 ------------------------------------- preload.js | 2 - ts/window.d.ts | 1 - 6 files changed, 29 insertions(+), 194 deletions(-) delete mode 100644 js/modules/loki_rss_api.js diff --git a/app/sql.js b/app/sql.js index 8c395d5da..086100c5b 100644 --- a/app/sql.js +++ b/app/sql.js @@ -106,7 +106,6 @@ module.exports = { updateConversation, removeConversation, getAllConversations, - getAllRssFeedConversations, getAllPublicConversations, getPublicConversationsByServer, getPubkeysInPublicConversation, @@ -810,6 +809,7 @@ const LOKI_SCHEMA_VERSIONS = [ updateToLokiSchemaVersion3, updateToLokiSchemaVersion4, updateToLokiSchemaVersion5, + updateToLokiSchemaVersion6, ]; async function updateToLokiSchemaVersion1(currentVersion, instance) { @@ -999,6 +999,34 @@ async function updateToLokiSchemaVersion5(currentVersion, instance) { console.log('updateToLokiSchemaVersion5: success!'); } +async function updateToLokiSchemaVersion6(currentVersion, instance) { + if (currentVersion >= 6) { + return; + } + + console.log('updateToLokiSchemaVersion6: starting...'); + + await instance.run('BEGIN TRANSACTION;'); + + // Remove RSS Feed conversations + await instance.run( + `DELETE FROM conversations WHERE + type = 'group' AND + id LIKE 'rss://%';` + ); + + await instance.run( + `INSERT INTO loki_schema ( + version + ) values ( + 6 + );` + ); + + await instance.run('COMMIT TRANSACTION;'); + console.log('updateToLokiSchemaVersion6: success!'); +} + async function updateLokiSchema(instance) { const result = await instance.get( "SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';" @@ -1905,17 +1933,6 @@ async function getAllPrivateConversations() { return map(rows, row => jsonToObject(row.json)); } -async function getAllRssFeedConversations() { - const rows = await db.all( - `SELECT json FROM conversations WHERE - type = 'group' AND - id LIKE 'rss://%' - ORDER BY id ASC;` - ); - - return map(rows, row => jsonToObject(row.json)); -} - async function getAllPublicConversations() { const rows = await db.all( `SELECT json FROM conversations WHERE diff --git a/js/background.js b/js/background.js index 48d63175f..45e5fa1e5 100644 --- a/js/background.js +++ b/js/background.js @@ -216,14 +216,6 @@ if (specialConvInited) { return; } - const rssFeedConversations = await window.Signal.Data.getAllRssFeedConversations( - { - ConversationCollection: Whisper.ConversationCollection, - } - ); - rssFeedConversations.forEach(conversation => { - window.feeds.push(new window.LokiRssAPI(conversation.getRssSettings())); - }); const publicConversations = await window.Signal.Data.getAllPublicConversations( { ConversationCollection: Whisper.ConversationCollection, diff --git a/js/modules/data.js b/js/modules/data.js index 1f27ff1d6..e532978e1 100644 --- a/js/modules/data.js +++ b/js/modules/data.js @@ -124,7 +124,6 @@ module.exports = { getAllConversations, getAllConversationIds, getAllPrivateConversations, - getAllRssFeedConversations, getAllPublicConversations, getPublicConversationsByServer, getPubkeysInPublicConversation, @@ -811,14 +810,6 @@ async function getAllConversationIds() { return ids; } -async function getAllRssFeedConversations({ ConversationCollection }) { - const conversations = await channels.getAllRssFeedConversations(); - - const collection = new ConversationCollection(); - collection.add(conversations); - return collection; -} - async function getAllPublicConversations({ ConversationCollection }) { const conversations = await channels.getAllPublicConversations(); diff --git a/js/modules/loki_rss_api.js b/js/modules/loki_rss_api.js deleted file mode 100644 index ff857ff78..000000000 --- a/js/modules/loki_rss_api.js +++ /dev/null @@ -1,162 +0,0 @@ -/* eslint-disable no-await-in-loop */ -/* eslint-disable no-loop-func */ -/* global log, window, textsecure */ - -const EventEmitter = require('events'); - -const PER_MIN = 60 * 1000; -const PER_HR = 60 * PER_MIN; -const RSS_POLL_EVERY = 1 * PER_HR; // once an hour - -function xml2json(xml) { - try { - let obj = {}; - if (xml.children.length > 0) { - for (let i = 0; i < xml.children.length; i += 1) { - const item = xml.children.item(i); - const { nodeName } = item; - - if (typeof obj[nodeName] === 'undefined') { - obj[nodeName] = xml2json(item); - } else { - if (typeof obj[nodeName].push === 'undefined') { - const old = obj[nodeName]; - - obj[nodeName] = []; - obj[nodeName].push(old); - } - obj[nodeName].push(xml2json(item)); - } - } - } else { - obj = xml.textContent; - } - return obj; - } catch (e) { - log.error(e.message); - } - return {}; -} - -class LokiRssAPI extends EventEmitter { - constructor(settings) { - super(); - // properties - this.feedUrl = settings.RSS_FEED; - this.groupId = settings.CONVO_ID; - this.feedTitle = settings.title; - this.closeable = settings.closeable; - // non configureable options - this.feedTimer = null; - // initial set up - this.getFeed(); - } - - async getFeed() { - // deal with file server proxy hardcoding - const map = { - 'https://loki.network/category/messenger-updates/feed/': - 'loki/v1/rss/messenger', - 'https://loki.network/feed/': 'loki/v1/rss/loki', - }; - if (map[this.feedUrl] === undefined) { - log.warn('LokiRssAPI unsupported rss feed', this.feedUrl); - return; - } - const result = await window.tokenlessFileServerAdnAPI.serverRequest( - map[this.feedUrl] - ); - if (!result) { - log.error('LokiRssAPI empty rss proxy response'); - return; - } - if (!result.response) { - log.error('LokiRssAPI rss proxy error, no response', result); - return; - } - if (!result.response.data) { - log.error( - 'LokiRssAPI rss proxy error, no data, response', - typeof result.response, - result.response - ); - return; - } - const responseXML = result.response.data; - let feedDOM = {}; - try { - feedDOM = await new window.DOMParser().parseFromString( - responseXML, - 'text/xml' - ); - } catch (e) { - log.error('LokiRssAPI xml parsing error', e, responseXML); - return; - } - const feedObj = xml2json(feedDOM); - let receivedAt = new Date().getTime(); - - if (!feedObj || !feedObj.rss || !feedObj.rss.channel) { - log.error( - 'LokiRssAPI rss structure error', - feedObj, - feedDOM, - responseXML - ); - return; - } - if (!feedObj.rss.channel.item) { - // no records, not an error - return; - } - if (feedObj.rss.channel.item.constructor !== Array) { - // Treat single record as array for consistency - feedObj.rss.channel.item = [feedObj.rss.channel.item]; - } - feedObj.rss.channel.item.reverse().forEach(item => { - // log.debug('item', item) - - const pubDate = new Date(item.pubDate); - - // if we use group style, we can put the title in the source - const messageData = { - isSessionRequest: false, - source: this.groupId, - sourceDevice: 1, - timestamp: pubDate.getTime(), - serverTimestamp: pubDate.getTime(), - receivedAt, - isRss: true, - message: { - body: `

${item.title}

${item.description}`, - attachments: [], - group: { - id: this.groupId, - type: textsecure.protobuf.GroupContext.Type.DELIVER, - }, - flags: 0, - expireTimer: 0, - profileKey: null, - timestamp: pubDate.getTime(), - received_at: receivedAt, - sent_at: pubDate.getTime(), - quote: null, - contact: [], - preview: [], - profile: null, - }, - }; - receivedAt += 1; // Ensure different arrival times - this.emit('rssMessage', { - message: messageData, - }); - }); - const ref = this; - function callTimer() { - ref.getFeed(); - } - this.feedTimer = setTimeout(callTimer, RSS_POLL_EVERY); - } -} - -module.exports = LokiRssAPI; diff --git a/preload.js b/preload.js index ca4ccba52..acfec5268 100644 --- a/preload.js +++ b/preload.js @@ -355,8 +355,6 @@ window.LokiPublicChatAPI = require('./js/modules/loki_public_chat_api'); window.LokiFileServerAPI = require('./js/modules/loki_file_server_api'); -window.LokiRssAPI = require('./js/modules/loki_rss_api'); - window.mnemonic = require('./libloki/modules/mnemonic'); const WorkerInterface = require('./js/modules/util_worker_interface'); diff --git a/ts/window.d.ts b/ts/window.d.ts index 240c3bc3b..f6d15c2d6 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -25,7 +25,6 @@ declare global { LokiAppDotNetServerAPI: any; LokiFileServerAPI: any; LokiPublicChatAPI: any; - LokiRssAPI: any; LokiSnodeAPI: any; MessageController: any; Session: any; From b04a64da8ce67fc8bc849f3dcc1d81f991c28cc8 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 16 Jul 2020 14:08:53 +1000 Subject: [PATCH 10/17] mark secondary devices as secondary from the right primary key --- ts/receiver/multidevice.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/ts/receiver/multidevice.ts b/ts/receiver/multidevice.ts index 7824882b4..6dd9142b6 100644 --- a/ts/receiver/multidevice.ts +++ b/ts/receiver/multidevice.ts @@ -338,33 +338,29 @@ async function onContactReceived(details: any) { activeAt = activeAt || Date.now(); conversation.set('active_at', activeAt); } - const ourPrimaryKey = window.storage.get('primaryDevicePubKey'); - if (ourPrimaryKey) { - const ourSecondaryDevices = await MultiDeviceProtocol.getSecondaryDevices( - ourPrimaryKey - ); - if (ourSecondaryDevices.some(device => device.key === id)) { - await conversation.setSecondaryStatus(true, ourPrimaryKey); - } - } - const devices = await MultiDeviceProtocol.getAllDevices(id); - const deviceConversations = await Promise.all( - devices.map(d => - ConversationController.getOrCreateAndWait(d.key, 'private') - ) - ); + const primaryDevice = await MultiDeviceProtocol.getPrimaryDevice(id); const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices(id); - await Promise.all( + const primaryConversation = await ConversationController.getOrCreateAndWait( + primaryDevice.key, + 'private' + ); + const secondaryConversations = await Promise.all( secondaryDevices.map(async d => { const secondaryConv = await ConversationController.getOrCreateAndWait( d.key, 'private' ); - await secondaryConv.setSecondaryStatus(true, id); + await secondaryConv.setSecondaryStatus(true, primaryDevice.key); + return conversation; }) ); + const deviceConversations = [ + primaryConversation, + ...secondaryConversations, + ]; + // triger session request with every devices of that user // when we do not have a session with it already deviceConversations.forEach(device => { From da4c9e47a152c67eaecd894099285df8a65ba4eb Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 16 Jul 2020 14:55:15 +1000 Subject: [PATCH 11/17] Bump to version 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91dedb27c..5d40d6722 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-messenger-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.0.9", + "version": "2.0.0", "license": "GPL-3.0", "author": { "name": "Loki Project", From 0f088c69fa93d928896149eccedecf2b39edf182 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 16 Jul 2020 16:14:21 +1000 Subject: [PATCH 12/17] Change version to 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d40d6722..06f52c276 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-messenger-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "2.0.0", + "version": "1.1.0", "license": "GPL-3.0", "author": { "name": "Loki Project", From afe8bc1e46d122f9adef7e269c607f0b76a92910 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 17 Jul 2020 09:33:23 +1000 Subject: [PATCH 13/17] Fix auto update checking --- background.html | 1 - background_test.html | 1 - js/background.js | 4 ++++ package.json | 2 +- test/index.html | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/background.html b/background.html index ad3063e11..db453bb99 100644 --- a/background.html +++ b/background.html @@ -456,7 +456,6 @@ - diff --git a/background_test.html b/background_test.html index cbb09488c..c6a198b6e 100644 --- a/background_test.html +++ b/background_test.html @@ -456,7 +456,6 @@ - diff --git a/js/background.js b/js/background.js index 45e5fa1e5..f193f266d 100644 --- a/js/background.js +++ b/js/background.js @@ -1472,6 +1472,10 @@ return; } + if (firstRun) { + window.readyForUpdates(); + } + if (!Whisper.Registration.everDone()) { return; } diff --git a/package.json b/package.json index 06f52c276..a9e197736 100644 --- a/package.json +++ b/package.json @@ -299,7 +299,7 @@ "!**/node_modules/*/build/**", "!**/*.{o,hprof,orig,pyc,pyo,rbc}", "!**/._*", - "!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.editorconfig,.flowconfig,.yarn-metadata.json,.idea,appveyor.yml,.travis.yml,circle.yml,npm-debug.log,.nyc_output,yarn.lock,.yarn-integrity}", + "!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.editorconfig,.flowconfig,.yarn-metadata.json,.idea,appveyor.yml,.travis.yml,circle.yml,npm-debug.log,.nyc_output,yarn.lock,.yarn-integrity,.map}", "node_modules/spellchecker/build/Release/*.node", "node_modules/websocket/build/Release/*.node", "node_modules/socks/build/*.js", diff --git a/test/index.html b/test/index.html index c98043693..7e9022a49 100644 --- a/test/index.html +++ b/test/index.html @@ -503,7 +503,6 @@ - From 0fde4495d6a4f0a93c562aea3e54189999682c43 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 17 Jul 2020 09:54:33 +1000 Subject: [PATCH 14/17] Update to v1.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a9e197736..b6935bb8a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-messenger-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.1.0", + "version": "1.1.1", "license": "GPL-3.0", "author": { "name": "Loki Project", From 38c0c53a6911eeb9222fbd95fff655e44f93b265 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 17 Jul 2020 14:22:24 +1000 Subject: [PATCH 15/17] Fix app start with password set by requiring only what is needed in the signal.js loaded by password_preload.js --- js/modules/signal_password.js | 15 +++++++++++++++ password_preload.js | 4 +--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 js/modules/signal_password.js diff --git a/js/modules/signal_password.js b/js/modules/signal_password.js new file mode 100644 index 000000000..64e6b551e --- /dev/null +++ b/js/modules/signal_password.js @@ -0,0 +1,15 @@ +// The idea with this file is to make it webpackable for the style guide + +const { + SessionPasswordPrompt, +} = require('../../ts/components/session/SessionPasswordPrompt'); + +exports.setup = () => { + const Components = { + SessionPasswordPrompt, + }; + + return { + Components, + }; +}; diff --git a/password_preload.js b/password_preload.js index e0cc712ef..04a8a2001 100644 --- a/password_preload.js +++ b/password_preload.js @@ -22,7 +22,7 @@ window.getVersion = () => config.version; window.getAppInstance = () => config.appInstance; // So far we're only using this for Signal.Types -const Signal = require('./js/modules/signal'); +const Signal = require('./js/modules/signal_password'); const electron = require('electron'); const ipc = electron.ipcRenderer; @@ -33,8 +33,6 @@ window.Signal = Signal.setup({ getRegionCode: () => null, }); -window.Signal.Logs = require('./js/modules/logs'); - window.CONSTANTS = { MAX_LOGIN_TRIES: 3, MAX_PASSWORD_LENGTH: 64, From 30964e5008b2fe22f6033bb3c77dab8625200a76 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 17 Jul 2020 14:33:32 +1000 Subject: [PATCH 16/17] load SessionPasswordPrompt directly from password_preload.js --- js/modules/signal_password.js | 15 --------------- password_preload.js | 17 +++++++++-------- 2 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 js/modules/signal_password.js diff --git a/js/modules/signal_password.js b/js/modules/signal_password.js deleted file mode 100644 index 64e6b551e..000000000 --- a/js/modules/signal_password.js +++ /dev/null @@ -1,15 +0,0 @@ -// The idea with this file is to make it webpackable for the style guide - -const { - SessionPasswordPrompt, -} = require('../../ts/components/session/SessionPasswordPrompt'); - -exports.setup = () => { - const Components = { - SessionPasswordPrompt, - }; - - return { - Components, - }; -}; diff --git a/password_preload.js b/password_preload.js index 04a8a2001..d499b1609 100644 --- a/password_preload.js +++ b/password_preload.js @@ -21,17 +21,18 @@ window.getEnvironment = () => config.environment; window.getVersion = () => config.version; window.getAppInstance = () => config.appInstance; -// So far we're only using this for Signal.Types -const Signal = require('./js/modules/signal_password'); const electron = require('electron'); const ipc = electron.ipcRenderer; - -window.Signal = Signal.setup({ - Attachments: null, - userDataPath: null, - getRegionCode: () => null, -}); +const { + SessionPasswordPrompt, +} = require('./ts/components/session/SessionPasswordPrompt'); + +window.Signal = { + Components: { + SessionPasswordPrompt, + }, +} window.CONSTANTS = { MAX_LOGIN_TRIES: 3, From d943a9401b786ce4a8d47dfd232d1fcfae0bb20a Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 17 Jul 2020 15:00:59 +1000 Subject: [PATCH 17/17] Bump version to 1.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b6935bb8a..d37bdca13 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-messenger-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.1.1", + "version": "1.1.2", "license": "GPL-3.0", "author": { "name": "Loki Project",