fix: update with latest libsession util

pull/2620/head
Audric Ackermann 2 years ago
parent 318a77be4b
commit bac2887c28

@ -98,7 +98,7 @@
"glob": "7.1.2", "glob": "7.1.2",
"image-type": "^4.1.0", "image-type": "^4.1.0",
"ip2country": "1.0.1", "ip2country": "1.0.1",
"libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.10/libsession_util_nodejs-v0.1.10.tar.gz", "libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.14/libsession_util_nodejs-v0.1.14.tar.gz",
"libsodium-wrappers-sumo": "^0.7.9", "libsodium-wrappers-sumo": "^0.7.9",
"linkify-it": "3.0.2", "linkify-it": "3.0.2",
"lodash": "^4.17.20", "lodash": "^4.17.20",

@ -34,7 +34,7 @@ function submitForOpenGroup(convoId: string, pubkeys: Array<string>) {
throw new Error(`getCommunityByFullUrl returned no result for ${convo.id}`); throw new Error(`getCommunityByFullUrl returned no result for ${convo.id}`);
} }
const groupInvitation = { const groupInvitation = {
url: roomDetails?.fullUrl, url: roomDetails?.fullUrlWithPubkey,
name: convo.getNicknameOrRealUsernameOrPlaceholder(), name: convo.getNicknameOrRealUsernameOrPlaceholder(),
}; };
pubkeys.forEach(async pubkeyStr => { pubkeys.forEach(async pubkeyStr => {

@ -39,28 +39,28 @@ import { BlockedNumberController } from '../util/blockedNumberController';
import { encryptProfile } from '../util/crypto/profileEncrypter'; import { encryptProfile } from '../util/crypto/profileEncrypter';
import { Storage, setLastProfileUpdateTimestamp } from '../util/storage'; import { Storage, setLastProfileUpdateTimestamp } from '../util/storage';
import { OpenGroupUtils } from '../session/apis/open_group_api/utils'; import { OpenGroupUtils } from '../session/apis/open_group_api/utils';
import { SessionUtilUserGroups } from '../session/utils/libsession/libsession_utils_user_groups';
import { leaveClosedGroup } from '../session/group/closed-group'; import { leaveClosedGroup } from '../session/group/closed-group';
import { SessionUtilContact } from '../session/utils/libsession/libsession_utils_contacts'; import { SessionUtilContact } from '../session/utils/libsession/libsession_utils_contacts';
import { SettingsKey } from '../data/settings-key'; import { SettingsKey } from '../data/settings-key';
import { ReleasedFeatures } from '../util/releaseFeature'; import { ReleasedFeatures } from '../util/releaseFeature';
import { UserGroupsWrapperActions } from '../webworker/workers/browser/libsession_worker_interface';
export function copyPublicKeyByConvoId(convoId: string) { export async function copyPublicKeyByConvoId(convoId: string) {
if (OpenGroupUtils.isOpenGroupV2(convoId)) { if (OpenGroupUtils.isOpenGroupV2(convoId)) {
const fromWrapper = SessionUtilUserGroups.getCommunityByConvoIdCached(convoId); const fromWrapper = await UserGroupsWrapperActions.getCommunityByFullUrl(convoId);
if (!fromWrapper) { if (!fromWrapper) {
throw new Error('opengroup to copy was not found in the UserGroupsWrapper'); window.log.warn('opengroup to copy was not found in the UserGroupsWrapper');
return;
} }
if (fromWrapper.fullUrl) { if (fromWrapper.fullUrlWithPubkey) {
window.clipboard.writeText(fromWrapper.fullUrl); window.clipboard.writeText(fromWrapper.fullUrlWithPubkey);
ToastUtils.pushCopiedToClipBoard();
} }
} else { } else {
window.clipboard.writeText(convoId); window.clipboard.writeText(convoId);
} }
ToastUtils.pushCopiedToClipBoard();
} }
export async function blockConvoById(conversationId: string) { export async function blockConvoById(conversationId: string) {

@ -1500,7 +1500,7 @@ function updateToSessionSchemaVersion30(currentVersion: number, db: BetterSqlite
/** /**
* Remove the `publicChat` prefix from the communities, instead keep the full url+room in it, with the corresponding http or https prefix. * Remove the `publicChat` prefix from the communities, instead keep the full url+room in it, with the corresponding http or https prefix.
* This is easier to handle with the libsession wrappers * This is easier to handle with the libsession wrappers
**/ */
const allOpengroupsConvo = db const allOpengroupsConvo = db
.prepare( .prepare(
`SELECT id FROM ${CONVERSATIONS_TABLE} WHERE `SELECT id FROM ${CONVERSATIONS_TABLE} WHERE

@ -214,7 +214,7 @@ async function handleCommunitiesUpdate() {
const allCommunitiesInWrapper = await UserGroupsWrapperActions.getAllCommunities(); const allCommunitiesInWrapper = await UserGroupsWrapperActions.getAllCommunities();
window.log.debug( window.log.debug(
'allCommunitiesInWrapper', 'allCommunitiesInWrapper',
allCommunitiesInWrapper.map(m => m.fullUrl) allCommunitiesInWrapper.map(m => m.fullUrlWithPubkey)
); );
const allCommunitiesConversation = getConversationController() const allCommunitiesConversation = getConversationController()
.getConversations() .getConversations()
@ -266,7 +266,7 @@ async function handleCommunitiesUpdate() {
// this call can take quite a long time and should not cause issues to not be awaited // this call can take quite a long time and should not cause issues to not be awaited
void Promise.all( void Promise.all(
communitiesToJoinInDB.map(async toJoin => { communitiesToJoinInDB.map(async toJoin => {
console.warn('joining community with convoId ', toJoin.fullUrl); window.log.info('joining community with convoId ', toJoin.fullUrlWithPubkey);
return getOpenGroupManager().attemptConnectionV2OneAtATime( return getOpenGroupManager().attemptConnectionV2OneAtATime(
toJoin.baseUrl, toJoin.baseUrl,
toJoin.roomCasePreserved, toJoin.roomCasePreserved,

@ -106,7 +106,7 @@ async function generateUpdateExpirySignature({
const ourEd25519Key = await UserUtils.getUserED25519KeyPair(); const ourEd25519Key = await UserUtils.getUserED25519KeyPair();
if (!ourEd25519Key) { if (!ourEd25519Key) {
const err = `getSnodeSignatureParams "expiry": User has no getUserED25519KeyPair()`; const err = 'getSnodeSignatureParams "expiry": User has no getUserED25519KeyPair()';
window.log.warn(err); window.log.warn(err);
throw new Error(err); throw new Error(err);
} }

@ -439,7 +439,9 @@ export class SwarmPolling {
)}` )}`
); );
} }
} catch (e) {} } catch (e) {
// nothing to do I suppose here.
}
results = results.slice(0, results.length - 1); results = results.slice(0, results.length - 1);
} }

@ -238,10 +238,10 @@ export class ConversationController {
try { try {
const fromWrapper = await UserGroupsWrapperActions.getCommunityByFullUrl(conversation.id); const fromWrapper = await UserGroupsWrapperActions.getCommunityByFullUrl(conversation.id);
if (fromWrapper?.fullUrl) { if (fromWrapper?.fullUrlWithPubkey) {
await SessionUtilConvoInfoVolatile.removeCommunityFromWrapper( await SessionUtilConvoInfoVolatile.removeCommunityFromWrapper(
conversation.id, conversation.id,
fromWrapper.fullUrl fromWrapper.fullUrlWithPubkey
); );
} }
} catch (e) { } catch (e) {

@ -299,7 +299,6 @@ async function queueNewJobIfNeeded() {
const leftBeforeNextTick = Math.max(defaultMsBetweenRetries - diff, 0); const leftBeforeNextTick = Math.max(defaultMsBetweenRetries - diff, 0);
window.log.debug('Scheduling ConfSyncJob: LATER'); window.log.debug('Scheduling ConfSyncJob: LATER');
// TODO we need to make the addJob wait for the previous addJob to be done before it can be called.
await runners.configurationSyncRunner.addJob( await runners.configurationSyncRunner.addJob(
new ConfigurationSyncJob({ nextAttemptTimestamp: Date.now() + leftBeforeNextTick }) new ConfigurationSyncJob({ nextAttemptTimestamp: Date.now() + leftBeforeNextTick })
); );
@ -309,5 +308,5 @@ async function queueNewJobIfNeeded() {
export const ConfigurationSync = { export const ConfigurationSync = {
ConfigurationSyncJob, ConfigurationSyncJob,
queueNewJobIfNeeded: () => queueNewJobIfNeeded: () =>
allowOnlyOneAtATime(`ConfigurationSyncJob-oneAtAtTime`, queueNewJobIfNeeded), allowOnlyOneAtATime('ConfigurationSyncJob-oneAtAtTime', queueNewJobIfNeeded),
}; };

@ -155,7 +155,7 @@ async function refreshCachedUserGroup(convoId: string, duringAppStart = false) {
let refreshed = false; let refreshed = false;
if (OpenGroupUtils.isOpenGroupV2(convoId)) { if (OpenGroupUtils.isOpenGroupV2(convoId)) {
const fromWrapper = await UserGroupsWrapperActions.getCommunityByFullUrl(convoId); const fromWrapper = await UserGroupsWrapperActions.getCommunityByFullUrl(convoId);
if (fromWrapper && fromWrapper.fullUrl) { if (fromWrapper && fromWrapper.fullUrlWithPubkey) {
mappedCommunityWrapperValues.set(convoId, fromWrapper); mappedCommunityWrapperValues.set(convoId, fromWrapper);
} }
refreshed = true; refreshed = true;
@ -190,7 +190,7 @@ async function removeCommunityFromWrapper(convoId: string, fullUrlWithOrWithoutP
); );
if (fromWrapper) { if (fromWrapper) {
await UserGroupsWrapperActions.eraseCommunityByFullUrl(fromWrapper.fullUrl); await UserGroupsWrapperActions.eraseCommunityByFullUrl(fromWrapper.fullUrlWithPubkey);
} }
mappedCommunityWrapperValues.delete(convoId); mappedCommunityWrapperValues.delete(convoId);
} }

@ -21,7 +21,7 @@ function getIsFeatureReleasedCached(featureName: FeatureNameTracked) {
case 'user_config_libsession': case 'user_config_libsession':
return isUserConfigLibsessionFeatureReleased; return isUserConfigLibsessionFeatureReleased;
default: default:
assertUnreachable(featureName, `case not handled for getIsFeatureReleasedCached`); assertUnreachable(featureName, 'case not handled for getIsFeatureReleasedCached');
} }
} }
@ -34,7 +34,7 @@ function setIsFeatureReleasedCached(featureName: FeatureNameTracked, value: bool
isUserConfigLibsessionFeatureReleased = value; isUserConfigLibsessionFeatureReleased = value;
break; break;
default: default:
assertUnreachable(featureName, `case not handled for setIsFeatureReleasedCached `); assertUnreachable(featureName, 'case not handled for setIsFeatureReleasedCached');
} }
} }
@ -47,11 +47,11 @@ function getFeatureReleaseTimestamp(featureName: FeatureNameTracked) {
case 'user_config_libsession': case 'user_config_libsession':
// TODO update to agreed value between platforms for `user_config_libsession` // TODO update to agreed value between platforms for `user_config_libsession`
return 1706778000000; // unix 01/02/2024 09:00; return (window as any).user_config_libsession || 1706778000000; // unix 01/02/2024 09:00;
// return 1677488400000; // testing: unix 27/02/2023 09:00 // return 1677488400000; // testing: unix 27/02/2023 09:00
default: default:
assertUnreachable(featureName, `case not handled for getFeatureReleaseTimestamp `); assertUnreachable(featureName, 'case not handled for getFeatureReleaseTimestamp');
} }
} }
@ -90,7 +90,7 @@ async function checkIsFeatureReleased(featureName: FeatureNameTracked): Promise<
return isReleased; return isReleased;
} }
function checkIsUserConfigFeatureReleased() { async function checkIsUserConfigFeatureReleased() {
return checkIsFeatureReleased('user_config_libsession'); return checkIsFeatureReleased('user_config_libsession');
} }

@ -149,9 +149,9 @@ function prepareErrorForPostMessage(error: any) {
return null; return null;
} }
if (error.stack) { // if (error.stack) {
return error.stack; // return error.stack;
} // }
return error.message; return error.message;
} }

@ -5148,9 +5148,9 @@ levn@~0.3.0:
prelude-ls "~1.1.2" prelude-ls "~1.1.2"
type-check "~0.3.2" type-check "~0.3.2"
"libsession_util_nodejs@https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.10/libsession_util_nodejs-v0.1.10.tar.gz": "libsession_util_nodejs@https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.14/libsession_util_nodejs-v0.1.14.tar.gz":
version "0.1.10" version "0.1.14"
resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.10/libsession_util_nodejs-v0.1.10.tar.gz#d508007fd15976bdb8b168234d7a7a2e54c7eaf8" resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.14/libsession_util_nodejs-v0.1.14.tar.gz#effb7e83ad6f09fb236b3f25497306b0236732ef"
dependencies: dependencies:
cmake-js "^7.2.1" cmake-js "^7.2.1"
node-addon-api "^6.1.0" node-addon-api "^6.1.0"

Loading…
Cancel
Save