fix: use TTL_CONFIG in retrieve request

also some comment cleanup
pull/2971/head
William Grant 2 years ago
parent b5bf6be691
commit a2185625c8

@ -1177,7 +1177,6 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
const messageHash = this.get('messageHash'); const messageHash = this.get('messageHash');
if (messageHash) { if (messageHash) {
// TODO Consolidate the snode /expire logic across all the different functions that call it.
await expireMessageOnSnode({ await expireMessageOnSnode({
messageHash, messageHash,
expireTimer: this.get('expireTimer'), expireTimer: this.get('expireTimer'),

@ -475,22 +475,18 @@ export async function innerHandleSwarmContentMessage(
content.dataMessage.profileKey = null; content.dataMessage.profileKey = null;
} }
// window.log.debug(
// `WIP: innerHandleSwarmContentMessage: running checkForExpireUpdateInContentMessage for ${envelope.id}`
// );
const expireUpdate = await checkForExpireUpdateInContentMessage( const expireUpdate = await checkForExpireUpdateInContentMessage(
content, content,
conversationModelForUIUpdate conversationModelForUIUpdate
); );
window.log.debug( // window.log.debug(
`WIP:innerHandleSwarmContentMessage: ${ // `WIP:innerHandleSwarmContentMessage: ${
content.dataMessage.syncTarget ? 'This is a sync message.\n' : '' // content.dataMessage.syncTarget ? 'This is a sync message.\n' : ''
} content: ${JSON.stringify(content)} ${ // } content: ${JSON.stringify(content)} ${
expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : '' // expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : ''
}` // }`
); // );
if (expireUpdate?.isOutdated) { if (expireUpdate?.isOutdated) {
window.log.debug(`WIP: ExpireUpdate is outdated. Ignoring it and removing from cache.`); window.log.debug(`WIP: ExpireUpdate is outdated. Ignoring it and removing from cache.`);

@ -5,7 +5,7 @@ import { doSnodeBatchRequest } from './batchRequest';
import { GetNetworkTime } from './getNetworkTime'; import { GetNetworkTime } from './getNetworkTime';
import { SnodeNamespace, SnodeNamespaces } from './namespaces'; import { SnodeNamespace, SnodeNamespaces } from './namespaces';
import { DURATION } from '../../constants'; import { TTL_DEFAULT } from '../../constants';
import { UserUtils } from '../../utils'; import { UserUtils } from '../../utils';
import { import {
RetrieveLegacyClosedGroupSubRequestType, RetrieveLegacyClosedGroupSubRequestType,
@ -74,7 +74,7 @@ async function buildRetrieveRequest(
); );
if (configHashesToBump?.length) { if (configHashesToBump?.length) {
const expiry = GetNetworkTime.getNowWithNetworkOffset() + DURATION.DAYS * 30; const expiry = GetNetworkTime.getNowWithNetworkOffset() + TTL_DEFAULT.TTL_CONFIG;
const signResult = await SnodeSignature.generateUpdateExpirySignature({ const signResult = await SnodeSignature.generateUpdateExpirySignature({
shortenOrExtend: '', shortenOrExtend: '',
timestamp: expiry, timestamp: expiry,

@ -96,12 +96,14 @@ async function getSnodeSignatureParams(params: {
} }
} }
/**
* NOTE if shortenOrExtend is an empty string it means we want to hardcode the expiry to a TTL value, otherwise it's to shorten or extend the TTL
*/
async function generateUpdateExpirySignature({ async function generateUpdateExpirySignature({
shortenOrExtend, shortenOrExtend,
timestamp, timestamp,
messageHashes, messageHashes,
}: { }: {
// NOTE empty string means we want to hardcode the expiry to a TTL value, otherwise it's a shorten or extension of the TTL
shortenOrExtend: 'extend' | 'shorten' | ''; shortenOrExtend: 'extend' | 'shorten' | '';
timestamp: number; timestamp: number;
messageHashes: Array<string>; messageHashes: Array<string>;

@ -53,7 +53,6 @@ export class ExpirableMessage extends ContentMessage {
return this.expirationType; return this.expirationType;
} }
// TODO legacy messages? + update expire endpoint for message after read
public ttl(): number { public ttl(): number {
switch (this.expirationType) { switch (this.expirationType) {
case 'deleteAfterSend': case 'deleteAfterSend':

Loading…
Cancel
Save