fix: linking allows legacy config message if one is found

pull/2620/head
Audric Ackermann 2 years ago
parent c0d69b0e00
commit ce63ce3797

@ -41,6 +41,7 @@ const ConversationListItemContextMenu = (props: PropsContextConversationItem) =>
if (isSearchingMode) { if (isSearchingMode) {
return null; return null;
} }
return ( return (
<SessionContextMenuContainer> <SessionContextMenuContainer>
<Menu id={triggerId} animation={animation.fade}> <Menu id={triggerId} animation={animation.fade}>

@ -35,6 +35,7 @@ import { ReleasedFeatures } from '../util/releaseFeature';
import { import {
Storage, Storage,
getLastProfileUpdateTimestamp, getLastProfileUpdateTimestamp,
isSignInByLinking,
setLastProfileUpdateTimestamp, setLastProfileUpdateTimestamp,
} from '../util/storage'; } from '../util/storage';
import { ConfigWrapperObjectTypes } from '../webworker/workers/browser/libsession_worker_functions'; import { ConfigWrapperObjectTypes } from '../webworker/workers/browser/libsession_worker_functions';
@ -767,7 +768,7 @@ async function handleOurProfileUpdateLegacy(
) { ) {
const userConfigLibsession = await ReleasedFeatures.checkIsUserConfigFeatureReleased(); const userConfigLibsession = await ReleasedFeatures.checkIsUserConfigFeatureReleased();
// we want to allow if we are not registered, as we might need to fetch an old config message (can be removed once we released for a weeks the libsession util) // we want to allow if we are not registered, as we might need to fetch an old config message (can be removed once we released for a weeks the libsession util)
if (userConfigLibsession && Registration.isDone()) { if (userConfigLibsession && !isSignInByLinking()) {
return; return;
} }
const latestProfileUpdateTimestamp = getLastProfileUpdateTimestamp(); const latestProfileUpdateTimestamp = getLastProfileUpdateTimestamp();
@ -978,7 +979,7 @@ async function handleConfigurationMessageLegacy(
// the process of those messages is always done after the process of the shared config messages, so that's only a fallback. // the process of those messages is always done after the process of the shared config messages, so that's only a fallback.
const userConfigLibsession = await ReleasedFeatures.checkIsUserConfigFeatureReleased(); const userConfigLibsession = await ReleasedFeatures.checkIsUserConfigFeatureReleased();
if (userConfigLibsession && Registration.isDone()) { if (userConfigLibsession && !isSignInByLinking()) {
window?.log?.info( window?.log?.info(
'useSharedUtilForUserConfig is set, not handling config messages with "handleConfigurationMessageLegacy()"' 'useSharedUtilForUserConfig is set, not handling config messages with "handleConfigurationMessageLegacy()"'
); );
@ -987,7 +988,7 @@ async function handleConfigurationMessageLegacy(
return; return;
} }
window?.log?.info('Handling configuration message'); window?.log?.info('Handling legacy configuration message');
const ourPubkey = UserUtils.getOurPubKeyStrFromCache(); const ourPubkey = UserUtils.getOurPubKeyStrFromCache();
if (!ourPubkey) { if (!ourPubkey) {
return; return;

@ -189,9 +189,11 @@ export async function TEST_fetchFromSeedWithRetriesAndWriteToDb() {
return; return;
} }
const start = Date.now();
try { try {
randomSnodePool = await SeedNodeAPI.fetchSnodePoolFromSeedNodeWithRetries(seedNodes); randomSnodePool = await SeedNodeAPI.fetchSnodePoolFromSeedNodeWithRetries(seedNodes);
await Data.updateSnodePoolOnDb(JSON.stringify(randomSnodePool)); await Data.updateSnodePoolOnDb(JSON.stringify(randomSnodePool));
window.log.info(`fetchSnodePoolFromSeedNodeWithRetries took ${Date.now() - start}ms`);
OnionPaths.resetPathFailureCount(); OnionPaths.resetPathFailureCount();
Onions.resetSnodeFailureCount(); Onions.resetSnodeFailureCount();

@ -431,7 +431,9 @@ export async function getGuardNodeOrSelectNewOnes() {
// If guard nodes is still empty (the old nodes are now invalid), select new ones: // If guard nodes is still empty (the old nodes are now invalid), select new ones:
if (guardNodes.length < desiredGuardCount) { if (guardNodes.length < desiredGuardCount) {
// if an error is thrown, the caller must take care of it. // if an error is thrown, the caller must take care of it.
const start = Date.now();
guardNodes = await OnionPaths.selectGuardNodes(); guardNodes = await OnionPaths.selectGuardNodes();
window.log.info(`OnionPaths.selectGuardNodes took ${Date.now() - start}ms`);
} }
} }

@ -176,8 +176,13 @@ async function createAccount(identityKeyPair: SessionKeyPair) {
await setLocalPubKey(pubKeyString); await setLocalPubKey(pubKeyString);
} }
/**
*
* @param ourPubkey the pubkey recovered from the seed
* @param displayName the display name entered by the user, if any. This is not a display name found from a config message in the network.
*/
async function registrationDone(ourPubkey: string, displayName: string) { async function registrationDone(ourPubkey: string, displayName: string) {
window?.log?.info('registration done'); window?.log?.info(`registration done with user provided displayName "${displayName}"`);
// initializeLibSessionUtilWrappers needs our publicKey to be set // initializeLibSessionUtilWrappers needs our publicKey to be set
await Storage.put('primaryDevicePubKey', ourPubkey); await Storage.put('primaryDevicePubKey', ourPubkey);
@ -208,5 +213,6 @@ async function registrationDone(ourPubkey: string, displayName: string) {
window.inboxStore?.dispatch(userActions.userChanged(user)); window.inboxStore?.dispatch(userActions.userChanged(user));
window?.log?.info('dispatching registration event'); window?.log?.info('dispatching registration event');
// this will make the poller start fetching messages, needed to find a configuration message
trigger('registration_done'); trigger('registration_done');
} }

@ -1,10 +1,7 @@
import { Storage } from './storage'; import { Storage } from './storage';
async function markEverDone() {
await Storage.put('chromiumRegistrationDoneEver', '');
}
async function markDone() { async function markDone() {
await markEverDone(); await Storage.put('chromiumRegistrationDoneEver', '');
await Storage.put('chromiumRegistrationDone', ''); await Storage.put('chromiumRegistrationDone', '');
} }
function isDone() { function isDone() {
@ -20,4 +17,4 @@ async function remove() {
await Storage.remove('chromiumRegistrationDone'); await Storage.remove('chromiumRegistrationDone');
} }
export const Registration = { markEverDone, markDone, isDone, everDone, remove }; export const Registration = { markDone, isDone, everDone, remove };

Loading…
Cancel
Save