diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 590574e04..0c80bce7c 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -2033,7 +2033,7 @@ function removeV2OpenGroupRoom(conversationId: string) { const configDumpData: ConfigDumpDataNode = { getConfigDumpByVariantAndPubkey: (variant: SharedConfigSupportedVariant, pubkey: string) => { const rows = assertGlobalInstance() - .prepare(`SELECT * from configDump WHERE variant = $variant AND pubkey = $pubkey;`) + .prepare('SELECT * from configDump WHERE variant = $variant AND pubkey = $pubkey;') .get({ pubkey, variant, @@ -2049,7 +2049,7 @@ const configDumpData: ConfigDumpDataNode = { getConfigDumpsByPubkey: (pubkey: string) => { const rows = assertGlobalInstance() - .prepare(`SELECT * from configDump WHERE pubkey = $pubkey;`) + .prepare('SELECT * from configDump WHERE pubkey = $pubkey;') .get({ pubkey, }); diff --git a/ts/session/apis/snode_api/swarmPolling.ts b/ts/session/apis/snode_api/swarmPolling.ts index ec7876e9e..44a95217d 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -139,11 +139,7 @@ export class SwarmPolling { // we always poll as often as possible for our pubkey const ourPubkey = UserUtils.getOurPubKeyFromCache(); const directPromise = Promise.all([ - this.pollOnceForKey(ourPubkey, false, [ - SnodeNamespaces.UserMessages, - SnodeNamespaces.UserProfile, - SnodeNamespaces.UserContacts, - ]), + this.pollOnceForKey(ourPubkey, false, this.getUserNamespacesPolled()), ]).then(() => undefined); const now = Date.now(); @@ -410,6 +406,12 @@ export class SwarmPolling { return newMessages; } + private getUserNamespacesPolled() { + return window.sessionFeatureFlags.useSharedUtilForUserConfig + ? [SnodeNamespaces.UserMessages, SnodeNamespaces.UserProfile, SnodeNamespaces.UserContacts] + : [SnodeNamespaces.UserMessages]; + } + private async updateLastHash({ edkey, expiration, diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test_skip.ts similarity index 94% rename from ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts rename to ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test_skip.ts index 516cc1b7f..09e28a1e3 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test_skip.ts @@ -1,7 +1,6 @@ import { expect } from 'chai'; import { from_hex, from_string } from 'libsodium-wrappers-sumo'; -import * as SessionUtilWrapper from 'session_util_wrapper'; // tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace @@ -17,6 +16,7 @@ describe('libsession_wrapper_contacts ', () => { const edSecretKey = from_hex( '0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' ); + const SessionUtilWrapper = require('session_util_wrapper'); // Initialize a brand new, empty config because we have no dump data to deal with. const contacts = new SessionUtilWrapper.ContactsConfigWrapper(edSecretKey, null); @@ -121,8 +121,8 @@ describe('libsession_wrapper_contacts ', () => { // Iterate through and make sure we got everything we expected const allContacts = contacts.getAll(); - const session_ids = allContacts.map(m => m.id); - const nicknames = allContacts.map(m => m.nickname || '(N/A)'); + const session_ids = allContacts.map((m: any) => m.id); + const nicknames = allContacts.map((m: any) => m.nickname || '(N/A)'); expect(session_ids.length).to.be.eq(2); expect(session_ids).to.be.deep.eq([real_id, another_id]); @@ -173,8 +173,8 @@ describe('libsession_wrapper_contacts ', () => { expect(contacts2.needsPush()).to.be.false; const allContacts2 = contacts.getAll(); - const session_ids2 = allContacts2.map(m => m.id); - const nicknames2 = allContacts2.map(m => m.nickname || '(N/A)'); + const session_ids2 = allContacts2.map((m: any) => m.id); + const nicknames2 = allContacts2.map((m: any) => m.nickname || '(N/A)'); expect(session_ids2.length).to.be.eq(2); expect(nicknames2.length).to.be.eq(2); @@ -186,6 +186,7 @@ describe('libsession_wrapper_contacts ', () => { const edSecretKey = from_hex( '0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' ); + const SessionUtilWrapper = require('session_util_wrapper'); // Initialize a brand new, empty config because we have no dump data to deal with. const contacts = new SessionUtilWrapper.ContactsConfigWrapper(edSecretKey, null); @@ -262,8 +263,8 @@ describe('libsession_wrapper_contacts ', () => { expect(accepted).to.be.equal(1); const allContacts2 = contacts.getAll(); - const session_ids2 = allContacts2.map(m => m.id); - const nicknames2 = allContacts2.map(m => m.nickname || '(N/A)'); + const session_ids2 = allContacts2.map((m: any) => m.id); + const nicknames2 = allContacts2.map((m: any) => m.nickname || '(N/A)'); expect(session_ids2.length).to.be.eq(2); expect(nicknames2.length).to.be.eq(2); @@ -276,7 +277,7 @@ describe('libsession_wrapper_contacts ', () => { const allContacts3 = contacts.getAll(); let deletions = 0; let non_deletions = 0; - allContacts3.forEach(c => { + allContacts3.forEach((c: any) => { if (c.id !== real_id) { contacts.erase(c.id); deletions++; diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts index 3aafb3d6f..e01e92059 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts @@ -3,7 +3,6 @@ import { expect } from 'chai'; import { stringToUint8Array } from '../../../../session/utils/String'; import { from_hex, to_hex } from 'libsodium-wrappers-sumo'; import { concatUInt8Array } from '../../../../session/crypto'; -import * as SessionUtilWrapper from 'session_util_wrapper'; // tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace @@ -19,6 +18,7 @@ describe('libsession_wrapper', () => { const edSecretKey = from_hex( '0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' ); + const SessionUtilWrapper = require('session_util_wrapper'); // Initialize a brand new, empty config because we have no dump data to deal with. const conf = new SessionUtilWrapper.UserConfigWrapper(edSecretKey, null); diff --git a/ts/test/test-utils/utils/stubbing.ts b/ts/test/test-utils/utils/stubbing.ts index 70b71b8a7..5cbd02810 100644 --- a/ts/test/test-utils/utils/stubbing.ts +++ b/ts/test/test-utils/utils/stubbing.ts @@ -2,6 +2,7 @@ import { expect } from 'chai'; import Sinon from 'sinon'; import { Data } from '../../../../ts/data/data'; import { OpenGroupData } from '../../../data/opengroups'; +import { ConfigDumpData } from '../../../data/configDump/configDump'; import * as utilWorker from '../../../webworker/workers/browser/util_worker_interface'; @@ -12,6 +13,7 @@ const globalAny: any = global; // tslint:disable: no-require-imports no-var-requires type DataFunction = typeof Data; type OpenGroupDataFunction = typeof OpenGroupData; +type ConfigDumpDataFunction = typeof ConfigDumpData; /** * Stub a function inside Data. @@ -27,6 +29,10 @@ export function stubOpenGroupData(fn: K): return Sinon.stub(OpenGroupData, fn); } +export function stubConfigDumpData(fn: K): sinon.SinonStub { + return Sinon.stub(ConfigDumpData, fn); +} + export function stubUtilWorker(fnName: string, returnedValue: any): sinon.SinonStub { return Sinon.stub(utilWorker, 'callUtilsWorker') .withArgs(fnName as any)