chore: cleanup FIXMEs and remove sig_timestamp as we cannot rely on it

we use timestamp instead of sig_timestamp for store requests
pull/2620/head
Audric Ackermann 2 years ago
parent f870eff45b
commit 22329bc745

@ -1062,7 +1062,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
options: { options: {
fromSync?: boolean; fromSync?: boolean;
} = {}, } = {},
shouldCommit = true, shouldCommit = true
): Promise<void> { ): Promise<void> {
let expireTimer = providedExpireTimer; let expireTimer = providedExpireTimer;
let source = providedSource; let source = providedSource;

@ -88,7 +88,7 @@ export type StoreOnNodeParams = {
timestamp: number; timestamp: number;
data: string; data: string;
namespace: number; namespace: number;
sig_timestamp?: number; // sig_timestamp?: number;
signature?: string; signature?: string;
pubkey_ed25519?: string; pubkey_ed25519?: string;
}; };

@ -5,7 +5,7 @@ import { GetNetworkTime } from './getNetworkTime';
export type SnodeSignatureResult = { export type SnodeSignatureResult = {
timestamp: number; timestamp: number;
sig_timestamp: number; // sig_timestamp: number;
signature: string; signature: string;
pubkey_ed25519: 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) 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); const signatureBase64 = fromUInt8ArrayToBase64(signature);
return { return {
sig_timestamp: signatureTimestamp, // sig_timestamp: signatureTimestamp,
timestamp: signatureTimestamp, timestamp: signatureTimestamp,
signature: signatureBase64, signature: signatureBase64,
pubkey_ed25519: ourEd25519Key.pubKey, pubkey_ed25519: ourEd25519Key.pubKey,

@ -244,8 +244,8 @@ export class SwarmPolling {
); );
} }
console.info(`received userConfigMessagesMerged: ${userConfigMessagesMerged.length}`); window.log.info(`received userConfigMessagesMerged: ${userConfigMessagesMerged.length}`);
console.info( window.log.info(
`received allNamespacesWithoutUserConfigIfNeeded: ${allNamespacesWithoutUserConfigIfNeeded.length}` `received allNamespacesWithoutUserConfigIfNeeded: ${allNamespacesWithoutUserConfigIfNeeded.length}`
); );

@ -74,7 +74,11 @@ export const sendDataExtractionNotification = async (
); );
try { try {
await getMessageQueue().sendToPubKey(pubkey, dataExtractionNotificationMessage, SnodeNamespaces.UserMessages); await getMessageQueue().sendToPubKey(
pubkey,
dataExtractionNotificationMessage,
SnodeNamespaces.UserMessages
);
} catch (e) { } catch (e) {
window.log.warn('failed to send data extraction notification', e); window.log.warn('failed to send data extraction notification', e);
} }

@ -204,7 +204,9 @@ async function sendMessagesDataToSnode(
namespace: item.namespace, namespace: item.namespace,
pubkey: item.pubkey, pubkey: item.pubkey,
timestamp: item.timestamp, 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, ttl: item.ttl,
...signOpts, ...signOpts,
}; };

@ -591,7 +591,7 @@ const findLastMessageTypeFromSender = (sender: string, msgType: SignalService.Ca
return undefined; 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 allMsg = _.flattenDeep([...msgCacheFromSenderWithDevices.values()]);
const allMsgFromType = allMsg.filter(m => m.type === msgType); const allMsgFromType = allMsg.filter(m => m.type === msgType);
const lastMessageOfType = _.last(allMsgFromType); const lastMessageOfType = _.last(allMsgFromType);

@ -214,7 +214,6 @@ function variantToKind(variant: ConfigWrapperObjectTypes): SignalService.SharedC
*/ */
async function markAsPushed(variant: ConfigWrapperObjectTypes, pubkey: string, seqno: number) { async function markAsPushed(variant: ConfigWrapperObjectTypes, pubkey: string, seqno: number) {
if (pubkey !== UserUtils.getOurPubKeyStrFromCache()) { if (pubkey !== UserUtils.getOurPubKeyStrFromCache()) {
//FIXME libsession closed group
throw new Error('FIXME, generic case is to be done'); throw new Error('FIXME, generic case is to be done');
} }
await GenericWrapperActions.confirmPushed(variant, seqno); await GenericWrapperActions.confirmPushed(variant, seqno);

@ -522,10 +522,6 @@ function handleMessageExpiredOrDeleted(
...state.messages.slice(messageInStoreIndex + 1), ...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 { return {
...state, ...state,
messages: editedMessages, messages: editedMessages,

@ -3,7 +3,7 @@ import { expect } from 'chai';
import { from_hex, from_string } from 'libsodium-wrappers-sumo'; 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 // 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', () => { describe('libsession_contacts', () => {
// Note: To run this test, you need to compile the libsession wrapper for node (and not for electron). // 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( const edSecretKey = from_hex(
'0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' '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. // Initialize a brand new, empty config because we have no dump data to deal with.
const contacts = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null); const contacts = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null);
@ -55,7 +55,7 @@ describe('libsession_contacts', () => {
created.approvedMe = true; created.approvedMe = true;
contacts.set(created); 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.null;
expect(updated).to.not.be.undefined; expect(updated).to.not.be.undefined;
@ -212,11 +212,7 @@ describe('libsession_contacts', () => {
c.nickname = 'Joey'; c.nickname = 'Joey';
c.approved = true; c.approved = true;
c.approvedMe = true; c.approvedMe = true;
contacts.set(c); // FIXME use .set when ready contacts.set(c);
// contacts.setName(real_id, c.name);
// contacts.setNickname(real_id, c.nickname);
// contacts.setApproved(real_id, c.approved);
// contacts.setApprovedMe(real_id, c.approvedMe);
const c2 = contacts.getOrCreate(realId); const c2 = contacts.getOrCreate(realId);
expect(c2.name).to.be.eq('Joe'); expect(c2.name).to.be.eq('Joe');
@ -230,7 +226,7 @@ describe('libsession_contacts', () => {
expect(contacts.needsDump()).to.be.true; expect(contacts.needsDump()).to.be.true;
expect(contacts.needsPush()).to.be.true; expect(contacts.needsPush()).to.be.true;
let push1 = contacts.push(); const push1 = contacts.push();
expect(push1.seqno).to.be.equal(1); expect(push1.seqno).to.be.equal(1);
const contacts2 = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null); const contacts2 = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null);
@ -262,7 +258,7 @@ describe('libsession_contacts', () => {
contacts2.set(c3); contacts2.set(c3);
let push2 = contacts2.push(); const push2 = contacts2.push();
accepted = contacts.merge([push2.data]); accepted = contacts.merge([push2.data]);
expect(accepted).to.be.equal(1); expect(accepted).to.be.equal(1);
@ -281,9 +277,9 @@ describe('libsession_contacts', () => {
const allContacts3 = contacts.getAll(); const allContacts3 = contacts.getAll();
let deletions = 0; let deletions = 0;
let non_deletions = 0; let non_deletions = 0;
allContacts3.forEach((c: any) => { allContacts3.forEach((contact: any) => {
if (c.id !== realId) { if (contact.id !== realId) {
contacts.erase(c.id); contacts.erase(contact.id);
deletions++; deletions++;
} else { } else {
non_deletions++; non_deletions++;

@ -4,7 +4,7 @@ import { stringToUint8Array } from '../../../../session/utils/String';
import { from_hex, to_hex } from 'libsodium-wrappers-sumo'; import { from_hex, to_hex } from 'libsodium-wrappers-sumo';
import { concatUInt8Array } from '../../../../session/crypto'; 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', () => { describe('libsession_wrapper', () => {
it('libsession_user', () => { it('libsession_user', () => {

@ -94,7 +94,7 @@ onmessage = async (e: { data: [number, ConfigWrapperObjectTypes, string, ...any]
return; return;
} }
const wrapper = await getCorrespondingWrapper(config); const wrapper = getCorrespondingWrapper(config);
const fn = (wrapper as any)[action]; const fn = (wrapper as any)[action];
if (!fn) { if (!fn) {

Loading…
Cancel
Save