From d8f02a2f089a0ce99d77ecf6439b0e2e08b9f1f0 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 10 Mar 2022 10:51:15 +1100 Subject: [PATCH 1/2] fix crash on startup for migration 21 with closed groups --- app/sql.js | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/app/sql.js b/app/sql.js index 4893aed9f..ecf7f05e8 100644 --- a/app/sql.js +++ b/app/sql.js @@ -2,11 +2,21 @@ const path = require('path'); const fs = require('fs'); const rimraf = require('rimraf'); const SQL = require('better-sqlite3'); -const { app, dialog, clipboard } = require('electron'); +const { app, dialog, clipboard, Notification } = require('electron'); const { redactAll } = require('../js/modules/privacy'); -const { remove: removeUserConfig } = require('./user_config'); -const { map, isString, fromPairs, forEach, last, isEmpty, isObject, isNumber } = require('lodash'); +const { + map, + flattenDeep, + uniq, + isString, + fromPairs, + forEach, + last, + isEmpty, + isObject, + isNumber, +} = require('lodash'); /* eslint-disable camelcase */ @@ -1392,16 +1402,17 @@ function updateToLokiSchemaVersion21(currentVersion, db) { `); // all closed group admins - const closedGroupRows = getAllClosedGroupConversations(db) || []; + const closedGroups = getAllClosedGroupConversations(db) || []; - const adminIds = closedGroupRows.map(json => jsonToObject(json).groupAdmins); - forEach(adminIds, id => { - db.exec( + const adminIds = closedGroups.map(g => g.groupAdmins); + const flattenedAdmins = uniq(flattenDeep(adminIds)) || []; + + forEach(flattenedAdmins, id => { + db.prepare( ` UPDATE ${CONVERSATIONS_TABLE} SET json = json_set(json, '$.didApproveMe', 1, '$.isApproved', 1) - WHERE type = id - values ($id); + WHERE id = $id; ` ).run({ id, @@ -1482,6 +1493,14 @@ function _initializePaths(configDir) { databaseFilePath = path.join(dbDir, 'db.sqlite'); } +function showFailedToStart() { + const notification = new Notification({ + title: 'Session failed to start', + body: 'Please start from terminal and open a github issue', + }); + notification.show(); +} + function initialize({ configDir, key, messages, passwordAttempt }) { if (globalInstance) { throw new Error('Cannot initialize more than once!'); @@ -1544,9 +1563,7 @@ function initialize({ configDir, key, messages, passwordAttempt }) { clipboard.writeText(`Database startup error:\n\n${redactAll(error.stack)}`); } else { close(); - removeDB(); - removeUserConfig(); - app.relaunch(); + showFailedToStart(); } app.exit(1); @@ -2314,8 +2331,8 @@ function getUnreadCountByConversation(conversationId) { function getMessageCountByType(conversationId, type = '%') { const row = globalInstance .prepare( - `SELECT count(*) from ${MESSAGES_TABLE} - WHERE conversationId = $conversationId + `SELECT count(*) from ${MESSAGES_TABLE} + WHERE conversationId = $conversationId AND type = $type;` ) .get({ From 6dfee3c528c448006e85f6a3e9cadf3b799ba5cf Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 10 Mar 2022 10:56:31 +1100 Subject: [PATCH 2/2] 1.7.8 without calls --- package.json | 2 +- preload.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 742aec818..4deefea3c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.8.2", + "version": "1.7.8", "license": "GPL-3.0", "author": { "name": "Oxen Labs", diff --git a/preload.js b/preload.js index 3d1cef324..77d1c83fb 100644 --- a/preload.js +++ b/preload.js @@ -31,7 +31,7 @@ window.getNodeVersion = () => config.node_version; window.sessionFeatureFlags = { useOnionRequests: true, - useCallMessage: true, + useCallMessage: false, }; window.versionInfo = {