From 86b15328c186b5b952474d5f0f667d24c16e02ab Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 21 Sep 2020 15:59:56 +1000 Subject: [PATCH 1/4] drop the prefix for group on the incoming message object --- ts/receiver/dataMessage.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 813b8b883..0818e037e 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -644,10 +644,8 @@ export async function handleMessageEvent(event: MessageEvent): Promise { // - group.id if it is a group message let conversationId = id; if (isGroupMessage) { - /* handle one part of the group logic here: - handle requesting info of a new group, - dropping an admin only update from a non admin, ... - */ + // remove the prefix from the source object so this is correct for all other + message.group.id = message.group.id.replace(PubKey.PREFIX_GROUP_TEXTSECURE, ''); conversationId = message.group.id; } From 4505bed61bf89ddae464d462ad3f1437e5cb2db6 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 22 Sep 2020 08:58:21 +1000 Subject: [PATCH 2/4] add migration to drop existing textsecure prefix from group convo ids --- app/sql.js | 57 ++++++++++++++++++++++++++++++++++++++ ts/receiver/dataMessage.ts | 5 +++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/app/sql.js b/app/sql.js index 225fb7e45..73dbdb5da 100644 --- a/app/sql.js +++ b/app/sql.js @@ -812,6 +812,7 @@ const LOKI_SCHEMA_VERSIONS = [ updateToLokiSchemaVersion6, updateToLokiSchemaVersion7, updateToLokiSchemaVersion8, + updateToLokiSchemaVersion9, ]; async function updateToLokiSchemaVersion1(currentVersion, instance) { @@ -1075,6 +1076,26 @@ async function updateToLokiSchemaVersion8(currentVersion, instance) { console.log('updateToLokiSchemaVersion8: success!'); } +async function updateToLokiSchemaVersion9(currentVersion, instance) { + if (currentVersion >= 9) { + return; + } + console.log('updateToLokiSchemaVersion9: starting...'); + await instance.run('BEGIN TRANSACTION;'); + + await removePrefixFromGroupConversations(instance); + + await instance.run( + `INSERT INTO loki_schema ( + version + ) values ( + 9 + );` + ); + await instance.run('COMMIT TRANSACTION;'); + console.log('updateToLokiSchemaVersion9: success!'); +} + async function updateLokiSchema(instance) { const result = await instance.get( "SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';" @@ -3039,3 +3060,39 @@ async function removeKnownAttachments(allAttachments) { return Object.keys(lookup); } + +async function removePrefixFromGroupConversations(instance) { + const rows = await instance.all( + `SELECT json FROM conversations WHERE + type = 'group' AND + id LIKE '__textsecure_group__!%';` + ); + + const objs = map(rows, row => jsonToObject(row.json)); + + await Promise.all( + objs.map(async o => { + const oldId = o.id; + const newId = oldId.replace('__textsecure_group__!', ''); + + console.log(`migrating conversation, ${oldId} to ${newId}`); + + const morphedObject = { + ...o, + id: newId, + }; + + await instance.run( + `UPDATE ${CONVERSATIONS_TABLE} SET + id = $newId, + json = $json + WHERE id = $oldId;`, + { + $newId: newId, + $json: objectToJSON(morphedObject), + $oldId: oldId, + } + ); + }) + ); +} diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 0818e037e..ea8049a71 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -645,7 +645,10 @@ export async function handleMessageEvent(event: MessageEvent): Promise { let conversationId = id; if (isGroupMessage) { // remove the prefix from the source object so this is correct for all other - message.group.id = message.group.id.replace(PubKey.PREFIX_GROUP_TEXTSECURE, ''); + message.group.id = message.group.id.replace( + PubKey.PREFIX_GROUP_TEXTSECURE, + '' + ); conversationId = message.group.id; } From 7011fa3efcecc1c14fd21336ff8db12ed9753bca Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 22 Sep 2020 08:58:53 +1000 Subject: [PATCH 3/4] drop the check for ttl in shouldSendNotify --- js/models/messages.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/models/messages.js b/js/models/messages.js index 1345f895a..d762d95c3 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1283,10 +1283,8 @@ (dataMessage.attachments && dataMessage.attachments.length)) ); const shouldNotifyPushServer = - hasBodyOrAttachments && - isSessionOrClosedMessage && - sentMessage.ttl === - window.libsession.Constants.TTL_DEFAULT.REGULAR_MESSAGE; + hasBodyOrAttachments && isSessionOrClosedMessage; + if (shouldNotifyPushServer) { // notify the push notification server if needed if (!wrappedEnvelope) { From e678895d178e9ad58ffe694905b6e3044cc6a693 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 22 Sep 2020 08:59:58 +1000 Subject: [PATCH 4/4] undo enable ssk groups --- preload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preload.js b/preload.js index ff5848175..ae826f80b 100644 --- a/preload.js +++ b/preload.js @@ -490,7 +490,7 @@ if (config.environment.includes('test-integration')) { useOnionRequests: false, useFileOnionRequests: false, debugMessageLogs: true, - enableSenderKeys: true, + enableSenderKeys: false, useMultiDevice: false, }; /* eslint-disable global-require, import/no-extraneous-dependencies */