From 7df1943f70c9f26a3031dd8f206b25773f56dcf1 Mon Sep 17 00:00:00 2001 From: aguestuser <aguestuser@riseup.net> Date: Mon, 9 Nov 2020 14:18:30 -0500 Subject: [PATCH] [hf] shorten expiry times for channels, hotline messages, invites shorten expiry times as follows: * channels: 4 weeks -> 1 week * hotline message joins: 4 weeks -> 3 days * invites: 2 weeks -> 1 week --- app/config/jobs.js | 10 +++++----- app/db/repositories/channel.js | 4 ++-- test/unit/db/repositories/channel.spec.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/config/jobs.js b/app/config/jobs.js index eb872ba0..9b7b93a9 100644 --- a/app/config/jobs.js +++ b/app/config/jobs.js @@ -1,11 +1,11 @@ const defaults = { - channelTimeToLive: 1000 * 60 * 60 * 24 * 28, // 4 weeks channelDestructionInterval: 1000 * 60 * 60, // 1 hr channelDestructionGracePeriod: 1000 * 60 * 60 * 24, // 1 day + channelExpiryInMillis: 1000 * 60 * 60 * 24 * 7, // 1 week healthcheckInterval: 1000 * 60 * 15, // 15 min - hotlineMessageExpiryInMillis: 1000 * 60 * 60 * 24 * 28, // 4 weeks + hotlineMessageExpiryInMillis: 1000 * 60 * 60 * 24 * 3, // 3 days inviteDeletionInterval: 1000 * 60 * 60, // 1 hour - inviteExpiryInMillis: 1000 * 60 * 60 * 24 * 14, // 2 weeks + inviteExpiryInMillis: 1000 * 60 * 60 * 24 * 7, // 1 week signaldStartupTime: 3000 * 60, // 3 min } @@ -13,9 +13,9 @@ const testInterval = 50 const development = { ...defaults, - channelTimeToLive: 1000 * 60 * 60 * 24 * 365 * 2, // 2 yr channelDestructionInterval: 1000 * 60 * 60 * 24, // 1 day channelDestructionGracePeriod: 1000 * 60 * 60 * 24 * 28, // 4 weeks + channelExpiryInMillis: 1000 * 60 * 60 * 24 * 365 * 2, // 2 yr healthcheckInterval: 1000 * 60 * 30, // 30 min signaldStartupTime: 1000 * 5, // 5 sec } @@ -23,8 +23,8 @@ const development = { const test = { ...defaults, testInterval, - channelTimeToLive: testInterval, channelDestructionInterval: testInterval, + channelExpiryInMillis: testInterval, healthcheckInterval: testInterval, // millis inviteDeletionInterval: testInterval, signaldStartupTime: 1, // millis diff --git a/app/db/repositories/channel.js b/app/db/repositories/channel.js index ddff7831..b06125d6 100644 --- a/app/db/repositories/channel.js +++ b/app/db/repositories/channel.js @@ -5,7 +5,7 @@ const { loggerOf } = require('../../util') const { memberTypes } = require('./membership') const { map } = require('lodash') const { - jobs: { channelTimeToLive }, + jobs: { channelExpiryInMillis }, signal: { diagnosticsPhoneNumber }, } = require('../../config') @@ -122,7 +122,7 @@ const getStaleChannels = async () => model: app.db.messageCount, where: { updatedAt: { - [Op.lte]: util.now().subtract(parseInt(channelTimeToLive), 'ms'), + [Op.lte]: util.now().subtract(parseInt(channelExpiryInMillis), 'ms'), }, }, }, diff --git a/test/unit/db/repositories/channel.spec.js b/test/unit/db/repositories/channel.spec.js index 66771e23..f290f54b 100644 --- a/test/unit/db/repositories/channel.spec.js +++ b/test/unit/db/repositories/channel.spec.js @@ -10,7 +10,7 @@ import { channelFactory, deepChannelFactory } from '../../../support/factories/c import { genPhoneNumber } from '../../../support/factories/phoneNumber' import { membershipFactory } from '../../../support/factories/membership' const { - jobs: { channelTimeToLive }, + jobs: { channelExpiryInMillis }, signal: { diagnosticsPhoneNumber }, } = require('../../../../app/config') @@ -390,7 +390,7 @@ describe('channel repository', () => { beforeEach(async () => { staleChannels = await createChannelsFromAttributes(times(2, deepChannelFactory)) - await util.wait(channelTimeToLive + 1) + await util.wait(channelExpiryInMillis + 1) await createChannelsFromAttributes(times(1, deepChannelFactory)) }) -- GitLab