From 22329bc74561779be2b909f35b555497737f5e75 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 14 Feb 2023 11:05:51 +1100 Subject: [PATCH] chore: cleanup FIXMEs and remove sig_timestamp as we cannot rely on it we use timestamp instead of sig_timestamp for store requests --- ts/models/conversation.ts | 2 +- .../apis/snode_api/SnodeRequestTypes.ts | 2 +- ts/session/apis/snode_api/snodeSignatures.ts | 4 ++-- ts/session/apis/snode_api/swarmPolling.ts | 4 ++-- .../DataExtractionNotificationMessage.ts | 6 ++++- ts/session/sending/MessageSender.ts | 4 +++- ts/session/utils/calling/CallManager.ts | 2 +- .../utils/libsession/libsession_utils.ts | 1 - ts/state/ducks/conversations.ts | 4 ---- .../libsession_wrapper_contacts_test.ts | 22 ++++++++----------- .../libsession_wrapper_test.ts | 2 +- .../node/libsession/libsession.worker.ts | 2 +- 12 files changed, 26 insertions(+), 29 deletions(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index a5eca70a3..1c6ad5df8 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1062,7 +1062,7 @@ export class ConversationModel extends Backbone.Model { options: { fromSync?: boolean; } = {}, - shouldCommit = true, + shouldCommit = true ): Promise { let expireTimer = providedExpireTimer; let source = providedSource; diff --git a/ts/session/apis/snode_api/SnodeRequestTypes.ts b/ts/session/apis/snode_api/SnodeRequestTypes.ts index 9900feee5..b5bfb21cf 100644 --- a/ts/session/apis/snode_api/SnodeRequestTypes.ts +++ b/ts/session/apis/snode_api/SnodeRequestTypes.ts @@ -88,7 +88,7 @@ export type StoreOnNodeParams = { timestamp: number; data: string; namespace: number; - sig_timestamp?: number; + // sig_timestamp?: number; signature?: string; pubkey_ed25519?: string; }; diff --git a/ts/session/apis/snode_api/snodeSignatures.ts b/ts/session/apis/snode_api/snodeSignatures.ts index dcc49af5a..2a6b20a89 100644 --- a/ts/session/apis/snode_api/snodeSignatures.ts +++ b/ts/session/apis/snode_api/snodeSignatures.ts @@ -5,7 +5,7 @@ import { GetNetworkTime } from './getNetworkTime'; export type SnodeSignatureResult = { timestamp: number; - sig_timestamp: number; + // sig_timestamp: number; signature: string; pubkey_ed25519: string; pubkey: string; // this is the x25519 key of the pubkey we are doing the request to (ourself for our swarm usually) @@ -82,7 +82,7 @@ async function getSnodeSignatureParams(params: { const signatureBase64 = fromUInt8ArrayToBase64(signature); return { - sig_timestamp: signatureTimestamp, + // sig_timestamp: signatureTimestamp, timestamp: signatureTimestamp, signature: signatureBase64, pubkey_ed25519: ourEd25519Key.pubKey, diff --git a/ts/session/apis/snode_api/swarmPolling.ts b/ts/session/apis/snode_api/swarmPolling.ts index 5e44f051e..426de7c99 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -244,8 +244,8 @@ export class SwarmPolling { ); } - console.info(`received userConfigMessagesMerged: ${userConfigMessagesMerged.length}`); - console.info( + window.log.info(`received userConfigMessagesMerged: ${userConfigMessagesMerged.length}`); + window.log.info( `received allNamespacesWithoutUserConfigIfNeeded: ${allNamespacesWithoutUserConfigIfNeeded.length}` ); diff --git a/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts b/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts index 1a9b8e955..562fb6ae1 100644 --- a/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/DataExtractionNotificationMessage.ts @@ -74,7 +74,11 @@ export const sendDataExtractionNotification = async ( ); try { - await getMessageQueue().sendToPubKey(pubkey, dataExtractionNotificationMessage, SnodeNamespaces.UserMessages); + await getMessageQueue().sendToPubKey( + pubkey, + dataExtractionNotificationMessage, + SnodeNamespaces.UserMessages + ); } catch (e) { window.log.warn('failed to send data extraction notification', e); } diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index 1b79431d0..372484749 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -204,7 +204,9 @@ async function sendMessagesDataToSnode( namespace: item.namespace, pubkey: item.pubkey, timestamp: item.timestamp, - sig_timestamp: item.timestamp, + // sig_timestamp: item.timestamp, + // sig_timestamp is currently not forwarded from the receiving snode to the other swarm members, and so their sig verify fail. + // This timestamp is not really needed so we just don't send it in the meantime (the timestamp value is used if the sig_timestamp is not present) ttl: item.ttl, ...signOpts, }; diff --git a/ts/session/utils/calling/CallManager.ts b/ts/session/utils/calling/CallManager.ts index be04987af..dc0887f04 100644 --- a/ts/session/utils/calling/CallManager.ts +++ b/ts/session/utils/calling/CallManager.ts @@ -591,7 +591,7 @@ const findLastMessageTypeFromSender = (sender: string, msgType: SignalService.Ca return undefined; } - // FIXME this does not sort by timestamp as we do not have a timestamp stored in the SignalService.CallMessage object... + // this does not sort by timestamp as we do not have a timestamp stored in the SignalService.CallMessage object const allMsg = _.flattenDeep([...msgCacheFromSenderWithDevices.values()]); const allMsgFromType = allMsg.filter(m => m.type === msgType); const lastMessageOfType = _.last(allMsgFromType); diff --git a/ts/session/utils/libsession/libsession_utils.ts b/ts/session/utils/libsession/libsession_utils.ts index 4151ceb53..3bdb039e0 100644 --- a/ts/session/utils/libsession/libsession_utils.ts +++ b/ts/session/utils/libsession/libsession_utils.ts @@ -214,7 +214,6 @@ function variantToKind(variant: ConfigWrapperObjectTypes): SignalService.SharedC */ async function markAsPushed(variant: ConfigWrapperObjectTypes, pubkey: string, seqno: number) { if (pubkey !== UserUtils.getOurPubKeyStrFromCache()) { - //FIXME libsession closed group throw new Error('FIXME, generic case is to be done'); } await GenericWrapperActions.confirmPushed(variant, seqno); diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 12c3fb9f2..878154032 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -522,10 +522,6 @@ function handleMessageExpiredOrDeleted( ...state.messages.slice(messageInStoreIndex + 1), ]; - // FIXME two other thing we have to do: - // * update the last message text if the message deleted was the last one - // * update the unread count of the convo if the message was the one counted as an unread - return { ...state, messages: editedMessages, 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.ts index f3811ca65..34449d954 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { from_hex, from_string } from 'libsodium-wrappers-sumo'; // tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace no-require-imports variable-name -import * as SessionUtilWrapper from 'session_util_wrapper'; +// import * as SessionUtilWrapper from 'session_util_wrapper'; describe('libsession_contacts', () => { // Note: To run this test, you need to compile the libsession wrapper for node (and not for electron). @@ -17,7 +17,7 @@ describe('libsession_contacts', () => { const edSecretKey = from_hex( '0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' ); - // const SessionUtilWrapper = require('session_util_wrapper'); + 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.ContactsConfigWrapperInsideWorker(edSecretKey, null); @@ -55,7 +55,7 @@ describe('libsession_contacts', () => { created.approvedMe = true; contacts.set(created); - let updated = contacts.get(real_id); + const updated = contacts.get(real_id); expect(updated).to.not.be.null; expect(updated).to.not.be.undefined; @@ -212,11 +212,7 @@ describe('libsession_contacts', () => { c.nickname = 'Joey'; c.approved = true; c.approvedMe = true; - contacts.set(c); // FIXME use .set when ready - // contacts.setName(real_id, c.name); - // contacts.setNickname(real_id, c.nickname); - // contacts.setApproved(real_id, c.approved); - // contacts.setApprovedMe(real_id, c.approvedMe); + contacts.set(c); const c2 = contacts.getOrCreate(realId); expect(c2.name).to.be.eq('Joe'); @@ -230,7 +226,7 @@ describe('libsession_contacts', () => { expect(contacts.needsDump()).to.be.true; expect(contacts.needsPush()).to.be.true; - let push1 = contacts.push(); + const push1 = contacts.push(); expect(push1.seqno).to.be.equal(1); const contacts2 = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null); @@ -262,7 +258,7 @@ describe('libsession_contacts', () => { contacts2.set(c3); - let push2 = contacts2.push(); + const push2 = contacts2.push(); accepted = contacts.merge([push2.data]); expect(accepted).to.be.equal(1); @@ -281,9 +277,9 @@ describe('libsession_contacts', () => { const allContacts3 = contacts.getAll(); let deletions = 0; let non_deletions = 0; - allContacts3.forEach((c: any) => { - if (c.id !== realId) { - contacts.erase(c.id); + allContacts3.forEach((contact: any) => { + if (contact.id !== realId) { + contacts.erase(contact.id); deletions++; } else { non_deletions++; diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts index 47eec9493..54f7d4760 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts @@ -4,7 +4,7 @@ import { stringToUint8Array } from '../../../../session/utils/String'; import { from_hex, to_hex } from 'libsodium-wrappers-sumo'; import { concatUInt8Array } from '../../../../session/crypto'; -// tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace +// tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace no-require-imports variable-name describe('libsession_wrapper', () => { it('libsession_user', () => { diff --git a/ts/webworker/workers/node/libsession/libsession.worker.ts b/ts/webworker/workers/node/libsession/libsession.worker.ts index 5f904d80c..6a0add291 100644 --- a/ts/webworker/workers/node/libsession/libsession.worker.ts +++ b/ts/webworker/workers/node/libsession/libsession.worker.ts @@ -94,7 +94,7 @@ onmessage = async (e: { data: [number, ConfigWrapperObjectTypes, string, ...any] return; } - const wrapper = await getCorrespondingWrapper(config); + const wrapper = getCorrespondingWrapper(config); const fn = (wrapper as any)[action]; if (!fn) {