|
|
@ -128,13 +128,14 @@ export const forceSyncConfigurationNowIfNeeded = async (waitForMessageSent = fal
|
|
|
|
const getNetworkTime = async (snode: Snode): Promise<string | number> => {
|
|
|
|
const getNetworkTime = async (snode: Snode): Promise<string | number> => {
|
|
|
|
const response: any = await snodeRpc('info', {}, snode);
|
|
|
|
const response: any = await snodeRpc('info', {}, snode);
|
|
|
|
const body = JSON.parse(response.body);
|
|
|
|
const body = JSON.parse(response.body);
|
|
|
|
const timestamp = body.timestamp;
|
|
|
|
const timestamp = body?.timestamp;
|
|
|
|
if (!timestamp) {
|
|
|
|
if (!timestamp) {
|
|
|
|
throw new Error(`getNetworkTime returned invalid timestamp: ${timestamp}`);
|
|
|
|
throw new Error(`getNetworkTime returned invalid timestamp: ${timestamp}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return timestamp;
|
|
|
|
return timestamp;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line: max-func-body-length
|
|
|
|
export const forceNetworkDeletion = async (): Promise<Map<string, boolean> | null> => {
|
|
|
|
export const forceNetworkDeletion = async (): Promise<Map<string, boolean> | null> => {
|
|
|
|
const sodium = await getSodium();
|
|
|
|
const sodium = await getSodium();
|
|
|
|
const userX25519PublicKey = UserUtils.getOurPubKeyFromCache();
|
|
|
|
const userX25519PublicKey = UserUtils.getOurPubKeyFromCache();
|
|
|
@ -147,11 +148,7 @@ export const forceNetworkDeletion = async (): Promise<Map<string, boolean> | nul
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const edKeyPriv = userED25519KeyPair.privKey;
|
|
|
|
const edKeyPriv = userED25519KeyPair.privKey;
|
|
|
|
|
|
|
|
|
|
|
|
console.warn({ userED25519KeyPair });
|
|
|
|
return pRetry(async () => {
|
|
|
|
console.warn({ edKeyPriv });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pRetry(
|
|
|
|
|
|
|
|
async () => {
|
|
|
|
|
|
|
|
const userSwarm = await getSwarmFor(userX25519PublicKey.key);
|
|
|
|
const userSwarm = await getSwarmFor(userX25519PublicKey.key);
|
|
|
|
const snodeToMakeRequestTo: Snode | undefined = _.sample(userSwarm);
|
|
|
|
const snodeToMakeRequestTo: Snode | undefined = _.sample(userSwarm);
|
|
|
|
const edKeyPrivBytes = fromHexToArray(edKeyPriv);
|
|
|
|
const edKeyPrivBytes = fromHexToArray(edKeyPriv);
|
|
|
@ -161,7 +158,6 @@ export const forceNetworkDeletion = async (): Promise<Map<string, boolean> | nul
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME audric pretry getNetworkTime separately too
|
|
|
|
|
|
|
|
return pRetry(
|
|
|
|
return pRetry(
|
|
|
|
async () => {
|
|
|
|
async () => {
|
|
|
|
const timestamp = await getNetworkTime(snodeToMakeRequestTo);
|
|
|
|
const timestamp = await getNetworkTime(snodeToMakeRequestTo);
|
|
|
@ -216,7 +212,6 @@ export const forceNetworkDeletion = async (): Promise<Map<string, boolean> | nul
|
|
|
|
swarmAsArray.map(snode => {
|
|
|
|
swarmAsArray.map(snode => {
|
|
|
|
const snodePubkey = snode[0];
|
|
|
|
const snodePubkey = snode[0];
|
|
|
|
const snodeJson = snode[1];
|
|
|
|
const snodeJson = snode[1];
|
|
|
|
console.warn({ snodePubkey, snodeJson });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isFailed = snodeJson.failed || false;
|
|
|
|
const isFailed = snodeJson.failed || false;
|
|
|
|
|
|
|
|
|
|
|
@ -268,10 +263,9 @@ export const forceNetworkDeletion = async (): Promise<Map<string, boolean> | nul
|
|
|
|
`delete_all request attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left...`
|
|
|
|
`delete_all request attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left...`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}, {});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const getActiveOpenGroupV2CompleteUrls = async (
|
|
|
|
const getActiveOpenGroupV2CompleteUrls = async (
|
|
|
@ -319,7 +313,7 @@ const getValidClosedGroups = async (convos: Array<ConversationModel>) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new ConfigurationMessageClosedGroup({
|
|
|
|
return new ConfigurationMessageClosedGroup({
|
|
|
|
publicKey: groupPubKey as string,
|
|
|
|
publicKey: groupPubKey,
|
|
|
|
name: c.get('name') || '',
|
|
|
|
name: c.get('name') || '',
|
|
|
|
members: c.get('members') || [],
|
|
|
|
members: c.get('members') || [],
|
|
|
|
admins: c.get('groupAdmins') || [],
|
|
|
|
admins: c.get('groupAdmins') || [],
|
|
|
|