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",
"image-type": "^4.1.0",
"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",
"linkify-it": "3.0.2",
"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}`);
}
const groupInvitation = {
url: roomDetails?.fullUrl,
url: roomDetails?.fullUrlWithPubkey,
name: convo.getNicknameOrRealUsernameOrPlaceholder(),
};
pubkeys.forEach(async pubkeyStr => {

@ -39,28 +39,28 @@ import { BlockedNumberController } from '../util/blockedNumberController';
import { encryptProfile } from '../util/crypto/profileEncrypter';
import { Storage, setLastProfileUpdateTimestamp } from '../util/storage';
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 { SessionUtilContact } from '../session/utils/libsession/libsession_utils_contacts';
import { SettingsKey } from '../data/settings-key';
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)) {
const fromWrapper = SessionUtilUserGroups.getCommunityByConvoIdCached(convoId);
const fromWrapper = await UserGroupsWrapperActions.getCommunityByFullUrl(convoId);
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) {
window.clipboard.writeText(fromWrapper.fullUrl);
if (fromWrapper.fullUrlWithPubkey) {
window.clipboard.writeText(fromWrapper.fullUrlWithPubkey);
ToastUtils.pushCopiedToClipBoard();
}
} else {
window.clipboard.writeText(convoId);
}
ToastUtils.pushCopiedToClipBoard();
}
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.
* This is easier to handle with the libsession wrappers
**/
*/
const allOpengroupsConvo = db
.prepare(
`SELECT id FROM ${CONVERSATIONS_TABLE} WHERE

@ -214,7 +214,7 @@ async function handleCommunitiesUpdate() {
const allCommunitiesInWrapper = await UserGroupsWrapperActions.getAllCommunities();
window.log.debug(
'allCommunitiesInWrapper',
allCommunitiesInWrapper.map(m => m.fullUrl)
allCommunitiesInWrapper.map(m => m.fullUrlWithPubkey)
);
const allCommunitiesConversation = getConversationController()
.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
void Promise.all(
communitiesToJoinInDB.map(async toJoin => {
console.warn('joining community with convoId ', toJoin.fullUrl);
window.log.info('joining community with convoId ', toJoin.fullUrlWithPubkey);
return getOpenGroupManager().attemptConnectionV2OneAtATime(
toJoin.baseUrl,
toJoin.roomCasePreserved,

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

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

@ -299,7 +299,6 @@ async function queueNewJobIfNeeded() {
const leftBeforeNextTick = Math.max(defaultMsBetweenRetries - diff, 0);
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(
new ConfigurationSyncJob({ nextAttemptTimestamp: Date.now() + leftBeforeNextTick })
);
@ -309,5 +308,5 @@ async function queueNewJobIfNeeded() {
export const ConfigurationSync = {
ConfigurationSyncJob,
queueNewJobIfNeeded: () =>
allowOnlyOneAtATime(`ConfigurationSyncJob-oneAtAtTime`, queueNewJobIfNeeded),
allowOnlyOneAtATime('ConfigurationSyncJob-oneAtAtTime', queueNewJobIfNeeded),
};

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

@ -21,7 +21,7 @@ function getIsFeatureReleasedCached(featureName: FeatureNameTracked) {
case 'user_config_libsession':
return isUserConfigLibsessionFeatureReleased;
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;
break;
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':
// 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
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;
}
function checkIsUserConfigFeatureReleased() {
async function checkIsUserConfigFeatureReleased() {
return checkIsFeatureReleased('user_config_libsession');
}

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

@ -5148,9 +5148,9 @@ levn@~0.3.0:
prelude-ls "~1.1.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":
version "0.1.10"
resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.10/libsession_util_nodejs-v0.1.10.tar.gz#d508007fd15976bdb8b168234d7a7a2e54c7eaf8"
"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.14"
resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.14/libsession_util_nodejs-v0.1.14.tar.gz#effb7e83ad6f09fb236b3f25497306b0236732ef"
dependencies:
cmake-js "^7.2.1"
node-addon-api "^6.1.0"

Loading…
Cancel
Save