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');
if (messageHash) {
// TODO Consolidate the snode /expire logic across all the different functions that call it.
await expireMessageOnSnode({
messageHash,
expireTimer: this.get('expireTimer'),

@ -475,22 +475,18 @@ export async function innerHandleSwarmContentMessage(
content.dataMessage.profileKey = null;
}
// window.log.debug(
// `WIP: innerHandleSwarmContentMessage: running checkForExpireUpdateInContentMessage for ${envelope.id}`
// );
const expireUpdate = await checkForExpireUpdateInContentMessage(
content,
conversationModelForUIUpdate
);
window.log.debug(
`WIP:innerHandleSwarmContentMessage: ${
content.dataMessage.syncTarget ? 'This is a sync message.\n' : ''
} content: ${JSON.stringify(content)} ${
expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : ''
}`
);
// window.log.debug(
// `WIP:innerHandleSwarmContentMessage: ${
// content.dataMessage.syncTarget ? 'This is a sync message.\n' : ''
// } content: ${JSON.stringify(content)} ${
// expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : ''
// }`
// );
if (expireUpdate?.isOutdated) {
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 { SnodeNamespace, SnodeNamespaces } from './namespaces';
import { DURATION } from '../../constants';
import { TTL_DEFAULT } from '../../constants';
import { UserUtils } from '../../utils';
import {
RetrieveLegacyClosedGroupSubRequestType,
@ -74,7 +74,7 @@ async function buildRetrieveRequest(
);
if (configHashesToBump?.length) {
const expiry = GetNetworkTime.getNowWithNetworkOffset() + DURATION.DAYS * 30;
const expiry = GetNetworkTime.getNowWithNetworkOffset() + TTL_DEFAULT.TTL_CONFIG;
const signResult = await SnodeSignature.generateUpdateExpirySignature({
shortenOrExtend: '',
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({
shortenOrExtend,
timestamp,
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' | '';
timestamp: number;
messageHashes: Array<string>;

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

Loading…
Cancel
Save