fix: disable expire timer tracking for all libsession logic

this will need to be turned on when the disappearing branch is merged
This commit is contained in:
Audric Ackermann 2023-06-23 07:58:52 +02:00
parent bec667ebee
commit 0e18bf4640
9 changed files with 52 additions and 51 deletions

View File

@ -100,7 +100,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.18/libsession_util_nodejs-v0.1.18.tar.gz", "libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.19/libsession_util_nodejs-v0.1.19.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.21", "lodash": "^4.17.21",

View File

@ -1223,7 +1223,7 @@ function insertContactIntoContactWrapper(
const dbApprovedMe = !!contact.didApproveMe || false; const dbApprovedMe = !!contact.didApproveMe || false;
const dbBlocked = blockedNumbers.includes(contact.id); const dbBlocked = blockedNumbers.includes(contact.id);
const priority = contact.priority || CONVERSATION_PRIORITIES.default; const priority = contact.priority || CONVERSATION_PRIORITIES.default;
const expirationTimerSeconds = contact.expireTimer || 0; // const expirationTimerSeconds = contact.expireTimer || 0;
const wrapperContact = getContactInfoFromDBValues({ const wrapperContact = getContactInfoFromDBValues({
id: contact.id, id: contact.id,
@ -1235,7 +1235,7 @@ function insertContactIntoContactWrapper(
dbProfileKey: contact.profileKey || undefined, dbProfileKey: contact.profileKey || undefined,
dbProfileUrl: contact.avatarPointer || undefined, dbProfileUrl: contact.avatarPointer || undefined,
priority, priority,
expirationTimerSeconds, // expirationTimerSeconds,
}); });
try { try {
@ -1259,7 +1259,7 @@ function insertContactIntoContactWrapper(
dbProfileKey: undefined, dbProfileKey: undefined,
dbProfileUrl: undefined, dbProfileUrl: undefined,
priority: CONVERSATION_PRIORITIES.default, priority: CONVERSATION_PRIORITIES.default,
expirationTimerSeconds: 0, // expirationTimerSeconds: 0,
}) })
); );
} catch (e) { } catch (e) {
@ -1373,7 +1373,7 @@ function insertCommunityIntoWrapper(
function insertLegacyGroupIntoWrapper( function insertLegacyGroupIntoWrapper(
legacyGroup: Pick< legacyGroup: Pick<
ConversationAttributes, ConversationAttributes,
'id' | 'priority' | 'expireTimer' | 'displayNameInProfile' | 'lastJoinedTimestamp' 'id' | 'priority' | 'displayNameInProfile' | 'lastJoinedTimestamp' // | 'expireTimer'
> & { members: string; groupAdmins: string }, // members and groupAdmins are still stringified here > & { members: string; groupAdmins: string }, // members and groupAdmins are still stringified here
userGroupConfigWrapper: UserGroupsWrapperNode, userGroupConfigWrapper: UserGroupsWrapperNode,
volatileInfoConfigWrapper: ConvoInfoVolatileWrapperNode, volatileInfoConfigWrapper: ConvoInfoVolatileWrapperNode,
@ -1382,7 +1382,7 @@ function insertLegacyGroupIntoWrapper(
const { const {
priority, priority,
id, id,
expireTimer, // expireTimer,
groupAdmins, groupAdmins,
members, members,
displayNameInProfile, displayNameInProfile,
@ -1397,7 +1397,7 @@ function insertLegacyGroupIntoWrapper(
const wrapperLegacyGroup = getLegacyGroupInfoFromDBValues({ const wrapperLegacyGroup = getLegacyGroupInfoFromDBValues({
id, id,
priority, priority,
expireTimer, // expireTimer,
groupAdmins, groupAdmins,
members, members,
displayNameInProfile, displayNameInProfile,
@ -1625,7 +1625,7 @@ function updateToSessionSchemaVersion31(currentVersion: number, db: BetterSqlite
const ourDbProfileUrl = ourConversation.avatarPointer || ''; const ourDbProfileUrl = ourConversation.avatarPointer || '';
const ourDbProfileKey = fromHexToArray(ourConversation.profileKey || ''); const ourDbProfileKey = fromHexToArray(ourConversation.profileKey || '');
const ourConvoPriority = ourConversation.priority; const ourConvoPriority = ourConversation.priority;
const ourConvoExpire = ourConversation.expireTimer || 0; // const ourConvoExpire = ourConversation.expireTimer || 0;
if (ourDbProfileUrl && !isEmpty(ourDbProfileKey)) { if (ourDbProfileUrl && !isEmpty(ourDbProfileKey)) {
userProfileWrapper.setUserInfo( userProfileWrapper.setUserInfo(
ourDbName, ourDbName,
@ -1634,7 +1634,7 @@ function updateToSessionSchemaVersion31(currentVersion: number, db: BetterSqlite
url: ourDbProfileUrl, url: ourDbProfileUrl,
key: ourDbProfileKey, key: ourDbProfileKey,
}, },
ourConvoExpire // ourConvoExpire
); );
} }

View File

@ -330,10 +330,10 @@ async function handleContactsUpdate(result: IncomingConfResult): Promise<Incomin
changes = true; changes = true;
} }
if (wrapperConvo.expirationTimerSeconds !== contactConvo.get('expireTimer')) { // if (wrapperConvo.expirationTimerSeconds !== contactConvo.get('expireTimer')) {
await contactConvo.updateExpireTimer(wrapperConvo.expirationTimerSeconds); // await contactConvo.updateExpireTimer(wrapperConvo.expirationTimerSeconds);
changes = true; // changes = true;
} // }
// we want to set the active_at to the created_at timestamp if active_at is unset, so that it shows up in our list. // we want to set the active_at to the created_at timestamp if active_at is unset, so that it shows up in our list.
if (!contactConvo.get('active_at') && wrapperConvo.createdAtSeconds) { if (!contactConvo.get('active_at') && wrapperConvo.createdAtSeconds) {
@ -558,17 +558,17 @@ async function handleLegacyGroupUpdate(latestEnvelopeTimestamp: number) {
changes = true; changes = true;
} }
if (legacyGroupConvo.get('expireTimer') !== fromWrapper.disappearingTimerSeconds) { // if (legacyGroupConvo.get('expireTimer') !== fromWrapper.disappearingTimerSeconds) {
await legacyGroupConvo.updateExpireTimer( // await legacyGroupConvo.updateExpireTimer(
fromWrapper.disappearingTimerSeconds, // fromWrapper.disappearingTimerSeconds,
undefined, // undefined,
latestEnvelopeTimestamp, // latestEnvelopeTimestamp,
{ // {
fromSync: true, // fromSync: true,
} // }
); // );
changes = true; // changes = true;
} // }
// start polling for this group if we haven't left it yet. The wrapper does not store this info for legacy group so we check from the DB entry instead // start polling for this group if we haven't left it yet. The wrapper does not store this info for legacy group so we check from the DB entry instead
if (!legacyGroupConvo.get('isKickedFromGroup') && !legacyGroupConvo.get('left')) { if (!legacyGroupConvo.get('isKickedFromGroup') && !legacyGroupConvo.get('left')) {
getSwarmPollingInstance().addGroupId(PubKey.cast(fromWrapper.pubkeyHex)); getSwarmPollingInstance().addGroupId(PubKey.cast(fromWrapper.pubkeyHex));

View File

@ -57,7 +57,8 @@ async function insertContactFromDBIntoWrapperAndRefresh(id: string): Promise<voi
const dbApprovedMe = !!foundConvo.get('didApproveMe') || false; const dbApprovedMe = !!foundConvo.get('didApproveMe') || false;
const dbBlocked = !!foundConvo.isBlocked() || false; const dbBlocked = !!foundConvo.isBlocked() || false;
const priority = foundConvo.get('priority') || 0; const priority = foundConvo.get('priority') || 0;
const expirationTimerSeconds = foundConvo.get('expireTimer') || 0; // expiration timer is not tracked currently but will be once disappearing message is merged into userconfig
// const expirationTimerSeconds = foundConvo.get('expireTimer') || 0;
const wrapperContact = getContactInfoFromDBValues({ const wrapperContact = getContactInfoFromDBValues({
id, id,
@ -69,7 +70,7 @@ async function insertContactFromDBIntoWrapperAndRefresh(id: string): Promise<voi
dbProfileKey, dbProfileKey,
dbProfileUrl, dbProfileUrl,
priority, priority,
expirationTimerSeconds, // expirationTimerSeconds,
}); });
try { try {
window.log.debug('inserting into contact wrapper: ', JSON.stringify(wrapperContact)); window.log.debug('inserting into contact wrapper: ', JSON.stringify(wrapperContact));

View File

@ -113,7 +113,7 @@ async function insertGroupsFromDBIntoWrapperAndRefresh(convoId: string): Promise
priority: foundConvo.get('priority'), priority: foundConvo.get('priority'),
members: foundConvo.get('members') || [], members: foundConvo.get('members') || [],
groupAdmins: foundConvo.get('groupAdmins') || [], groupAdmins: foundConvo.get('groupAdmins') || [],
expireTimer: foundConvo.get('expireTimer'), // expireTimer: foundConvo.get('expireTimer'),
displayNameInProfile: foundConvo.get('displayNameInProfile'), displayNameInProfile: foundConvo.get('displayNameInProfile'),
encPubkeyHex: encryptionKeyPair?.publicHex || '', encPubkeyHex: encryptionKeyPair?.publicHex || '',
encSeckeyHex: encryptionKeyPair?.privateHex || '', encSeckeyHex: encryptionKeyPair?.privateHex || '',

View File

@ -26,7 +26,7 @@ async function insertUserProfileIntoWrapper(convoId: string) {
{ url: dbProfileUrl, key: dbProfileKey } { url: dbProfileUrl, key: dbProfileKey }
)} ` )} `
); );
const expirySeconds = ourConvo.get('expireTimer') || 0; // const expirySeconds = ourConvo.get('expireTimer') || 0;
if (dbProfileUrl && !isEmpty(dbProfileKey)) { if (dbProfileUrl && !isEmpty(dbProfileKey)) {
await UserConfigWrapperActions.setUserInfo( await UserConfigWrapperActions.setUserInfo(
dbName, dbName,
@ -34,11 +34,11 @@ async function insertUserProfileIntoWrapper(convoId: string) {
{ {
url: dbProfileUrl, url: dbProfileUrl,
key: dbProfileKey, key: dbProfileKey,
}, }
expirySeconds // expirySeconds
); );
} else { } else {
await UserConfigWrapperActions.setUserInfo(dbName, priority, null, expirySeconds); await UserConfigWrapperActions.setUserInfo(dbName, priority, null); // expirySeconds
} }
} }

View File

@ -115,8 +115,8 @@ export function getContactInfoFromDBValues({
priority, priority,
dbProfileUrl, dbProfileUrl,
dbProfileKey, dbProfileKey,
expirationTimerSeconds, }: // expirationTimerSeconds,
}: { {
id: string; id: string;
dbApproved: boolean; dbApproved: boolean;
dbApprovedMe: boolean; dbApprovedMe: boolean;
@ -126,7 +126,7 @@ export function getContactInfoFromDBValues({
priority: number; priority: number;
dbProfileUrl: string | undefined; dbProfileUrl: string | undefined;
dbProfileKey: string | undefined; dbProfileKey: string | undefined;
expirationTimerSeconds: number | undefined; // expirationTimerSeconds: number | undefined;
}): ContactInfoSet { }): ContactInfoSet {
const wrapperContact: ContactInfoSet = { const wrapperContact: ContactInfoSet = {
id, id,
@ -136,14 +136,14 @@ export function getContactInfoFromDBValues({
priority, priority,
nickname: dbNickname, nickname: dbNickname,
name: dbName, name: dbName,
expirationTimerSeconds: // expirationTimerSeconds:
!!expirationTimerSeconds && isFinite(expirationTimerSeconds) && expirationTimerSeconds > 0 // !!expirationTimerSeconds && isFinite(expirationTimerSeconds) && expirationTimerSeconds > 0
? expirationTimerSeconds // ? expirationTimerSeconds
: 0, // TODOLATER add the expiration mode handling // : 0, // TODOLATER add the expiration mode handling
expirationMode: // expirationMode:
!!expirationTimerSeconds && isFinite(expirationTimerSeconds) && expirationTimerSeconds > 0 // !!expirationTimerSeconds && isFinite(expirationTimerSeconds) && expirationTimerSeconds > 0
? 'disappearAfterSend' // ? 'disappearAfterSend'
: 'off', // : 'off',
}; };
if ( if (
@ -199,14 +199,14 @@ export function getLegacyGroupInfoFromDBValues({
priority, priority,
members: maybeMembers, members: maybeMembers,
displayNameInProfile, displayNameInProfile,
expireTimer, // expireTimer,
encPubkeyHex, encPubkeyHex,
encSeckeyHex, encSeckeyHex,
groupAdmins: maybeAdmins, groupAdmins: maybeAdmins,
lastJoinedTimestamp, lastJoinedTimestamp,
}: Pick< }: Pick<
ConversationAttributes, ConversationAttributes,
'id' | 'priority' | 'displayNameInProfile' | 'expireTimer' | 'lastJoinedTimestamp' 'id' | 'priority' | 'displayNameInProfile' | 'lastJoinedTimestamp' //| 'expireTimer'
> & { > & {
encPubkeyHex: string; encPubkeyHex: string;
encSeckeyHex: string; encSeckeyHex: string;
@ -224,7 +224,7 @@ export function getLegacyGroupInfoFromDBValues({
}); });
const legacyGroup: LegacyGroupInfo = { const legacyGroup: LegacyGroupInfo = {
pubkeyHex: id, pubkeyHex: id,
disappearingTimerSeconds: !expireTimer ? 0 : expireTimer, // disappearingTimerSeconds: !expireTimer ? 0 : expireTimer,
name: displayNameInProfile || '', name: displayNameInProfile || '',
priority: priority || 0, priority: priority || 0,
members: wrappedMembers, members: wrappedMembers,

View File

@ -104,8 +104,8 @@ export const UserConfigWrapperActions: UserConfigWrapperActionsCalls = {
setUserInfo: async ( setUserInfo: async (
name: string, name: string,
priority: number, priority: number,
profilePic: { url: string; key: Uint8Array } | null, profilePic: { url: string; key: Uint8Array } | null
expireSeconds: number // expireSeconds: number
) => ) =>
callLibSessionWorker([ callLibSessionWorker([
'UserConfig', 'UserConfig',
@ -113,7 +113,7 @@ export const UserConfigWrapperActions: UserConfigWrapperActionsCalls = {
name, name,
priority, priority,
profilePic, profilePic,
expireSeconds, // expireSeconds,
]) as Promise<ReturnType<UserConfigWrapperActionsCalls['setUserInfo']>>, ]) as Promise<ReturnType<UserConfigWrapperActionsCalls['setUserInfo']>>,
}; };

View File

@ -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.18/libsession_util_nodejs-v0.1.18.tar.gz": "libsession_util_nodejs@https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.19/libsession_util_nodejs-v0.1.19.tar.gz":
version "0.1.18" version "0.1.19"
resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.18/libsession_util_nodejs-v0.1.18.tar.gz#2580c8b4d6c58da4c22108f88e13dd0cb2da54dc" resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.19/libsession_util_nodejs-v0.1.19.tar.gz#294c6e8ea6b767d375a9c0249bef98b65f3ae252"
dependencies: dependencies:
cmake-js "^7.2.1" cmake-js "^7.2.1"
node-addon-api "^6.1.0" node-addon-api "^6.1.0"