fixup duration missing

pull/1667/head
Audric Ackermann 4 years ago
parent 70248b470d
commit b15eeb00cd
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -6,7 +6,6 @@ import { SessionToastContainer } from './SessionToastContainer';
import { ConversationController } from '../../session/conversations';
import { UserUtils } from '../../session/utils';
import { syncConfigurationIfNeeded } from '../../session/utils/syncUtils';
import { DAYS, MINUTES } from '../../session/utils/Number';
import {
createOrUpdateItem,
@ -43,6 +42,7 @@ import { IMAGE_JPEG } from '../../types/MIME';
import { FSv2 } from '../../fileserver';
import { stringToArrayBuffer } from '../../session/utils/String';
import { debounce } from 'underscore';
import { DURATION } from '../../session/constants';
// tslint:disable-next-line: no-import-side-effect no-submodule-imports
export enum SectionType {
@ -153,7 +153,7 @@ const showResetSessionIDDialogIfNeeded = async () => {
window.showResetSessionIdDialog();
};
const cleanUpMediasInterval = MINUTES * 30;
const cleanUpMediasInterval = DURATION.MINUTES * 30;
const setupTheme = (dispatch: Dispatch<any>) => {
const theme = window.Events.getThemeSetting();
@ -175,7 +175,7 @@ const triggerSyncIfNeeded = async () => {
const triggerAvatarReUploadIfNeeded = async () => {
const lastTimeStampAvatarUpload = (await getItemById(lastAvatarUploadTimestamp))?.value || 0;
if (Date.now() - lastTimeStampAvatarUpload > DAYS * 14) {
if (Date.now() - lastTimeStampAvatarUpload > DURATION.DAYS * 14) {
window.log.info('Reuploading avatar...');
// reupload the avatar
const ourConvo = ConversationController.getInstance().get(UserUtils.getOurPubKeyStrFromCache());
@ -323,16 +323,16 @@ export const ActionsPanel = () => {
useInterval(() => {
void syncConfigurationIfNeeded();
}, DAYS * 2);
}, DURATION.DAYS * 2);
useInterval(() => {
void forceRefreshRandomSnodePool();
}, DAYS * 1);
}, DURATION.DAYS * 1);
useInterval(() => {
// this won't be run every days, but if the app stays open for more than 10 days
void triggerAvatarReUploadIfNeeded();
}, DAYS * 1);
}, DURATION.DAYS * 1);
return (
<div className="module-left-pane__sections-container">

@ -10,6 +10,7 @@ import { sendViaOnion } from '../../session/onions/onionSend';
import { OpenGroupMessageV2 } from './OpenGroupMessageV2';
import { downloadPreviewOpenGroupV2, getMemberCount } from './OpenGroupAPIV2';
import { getAuthToken } from './ApiAuth';
import { DURATION } from '../../session/constants';
const COMPACT_POLL_ENDPOINT = 'compact_poll';

@ -17,15 +17,15 @@ import { getMessageIdsFromServerIds, removeMessage } from '../../data/data';
import { getV2OpenGroupRoom, OpenGroupV2Room, saveV2OpenGroupRoom } from '../../data/opengroups';
import { OpenGroupMessageV2 } from './OpenGroupMessageV2';
import { handleOpenGroupV2Message } from '../../receiver/receiver';
import { DAYS, MINUTES, SECONDS } from '../../session/utils/Number';
import autoBind from 'auto-bind';
import { sha256 } from '../../session/crypto';
import { fromBase64ToArrayBuffer } from '../../session/utils/String';
import { getAuthToken } from './ApiAuth';
import { DURATION } from '../../session/constants';
const pollForEverythingInterval = SECONDS * 4;
const pollForRoomAvatarInterval = DAYS * 1;
const pollForMemberCountInterval = MINUTES * 10;
const pollForEverythingInterval = DURATION.SECONDS * 4;
const pollForRoomAvatarInterval = DURATION.DAYS * 1;
const pollForMemberCountInterval = DURATION.MINUTES * 10;
/**
* An OpenGroupServerPollerV2 polls for everything for a particular server. We should

@ -1,5 +1,5 @@
import { DURATION } from '../session/constants';
import { PubKey } from '../session/types';
import { SECONDS } from '../session/utils/Number';
/**
* Singleton handling the logic behing requesting EncryptionKeypair for a closed group we need.
@ -7,7 +7,7 @@ import { SECONDS } from '../session/utils/Number';
* Nothing is read/written to the db, it's all on memory for now.
*/
export class KeyPairRequestManager {
public static DELAY_BETWEEN_TWO_REQUEST_MS = SECONDS * 30;
public static DELAY_BETWEEN_TWO_REQUEST_MS = DURATION.SECONDS * 30;
private static instance: KeyPairRequestManager | null;
private readonly requestTimestamps: Map<string, number>;

@ -1,9 +1,20 @@
import { DAYS, SECONDS } from './utils/Number';
// tslint:disable: binary-expression-operand-order
const seconds = 1000;
const minutes = seconds * 60;
const hours = minutes * 60;
const days = hours * 24;
export const DURATION = {
SECONDS: seconds, // in ms
MINUTES: minutes, // in ms
HOURS: hours, // in ms
DAYS: days, // in ms
};
export const TTL_DEFAULT = {
TYPING_MESSAGE: 20 * SECONDS,
TTL_MAX: 14 * DAYS,
TYPING_MESSAGE: 20 * DURATION.SECONDS,
TTL_MAX: 14 * DURATION.DAYS,
};
export const PROTOCOLS = {

@ -9,7 +9,7 @@
import toArrayBuffer from 'to-arraybuffer';
import * as fse from 'fs-extra';
import { decryptAttachmentBuffer } from '../../types/Attachment';
import { HOURS } from '../utils/Number';
import { DURATION } from '../constants';
// FIXME.
// add a way to remove the blob when the attachment file path is removed (message removed?)
@ -23,7 +23,7 @@ export const cleanUpOldDecryptedMedias = () => {
window?.log?.info('Starting cleaning of medias blobs...');
for (const iterator of urlToDecryptedBlobMap) {
// if the last access is older than one hour, revoke the url and remove it.
if (iterator[1].lastAccessTimestamp < currentTimestamp - HOURS * 1) {
if (iterator[1].lastAccessTimestamp < currentTimestamp - DURATION.HOURS * 1) {
URL.revokeObjectURL(iterator[1].decrypted);
urlToDecryptedBlobMap.delete(iterator[0]);
countCleaned++;

@ -1,5 +0,0 @@
export const MINUTES = 60 * 1000; // in ms
export const SECONDS = 1000; // in ms
// tslint:disable: binary-expression-operand-order
export const HOURS = 60 * MINUTES; // in ms
export const DAYS = 24 * HOURS; // in ms

@ -1,7 +1,6 @@
import * as MessageUtils from './Messages';
import * as GroupUtils from './Groups';
import * as StringUtils from './String';
import * as NumberUtils from './Number';
import * as PromiseUtils from './Promise';
import * as ProtobufUtils from './Protobuf';
import * as MenuUtils from '../../components/session/menu/Menu';
@ -19,7 +18,6 @@ export {
MessageUtils,
GroupUtils,
StringUtils,
NumberUtils,
PromiseUtils,
ProtobufUtils,
MenuUtils,

@ -5,7 +5,6 @@ import {
} from '../../../ts/data/data';
import { getMessageQueue } from '..';
import { ConversationController } from '../conversations';
import { DAYS } from './Number';
import uuid from 'uuid';
import { UserUtils } from '.';
import { ECKeyPair } from '../../receiver/keypairs';
@ -28,6 +27,7 @@ import {
import { ExpirationTimerUpdateMessage } from '../messages/outgoing/controlMessage/ExpirationTimerUpdateMessage';
import { getV2OpenGroupRoom } from '../../data/opengroups';
import { getCompleteUrlFromRoom } from '../../opengroup/utils/OpenGroupUtils';
import { DURATION } from '../constants';
const ITEM_ID_LAST_SYNC_TIMESTAMP = 'lastSyncedTimestamp';
@ -42,7 +42,7 @@ export const syncConfigurationIfNeeded = async () => {
const now = Date.now();
// if the last sync was less than 2 days before, return early.
if (Math.abs(now - lastSyncedTimestamp) < DAYS * 7) {
if (Math.abs(now - lastSyncedTimestamp) < DURATION.DAYS * 7) {
return;
}

Loading…
Cancel
Save