Skip to content

Commit 286b031

Browse files
committed
Prune open groups larger than 10000 messages of those > 12 months old.
1 parent e329dac commit 286b031

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

_locales/en/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"oceanDarkThemeTitle": "Ocean Dark",
161161
"oceanLightThemeTitle": "Ocean Light",
162162
"pruneSettingTitle": "Trim Communities",
163-
"pruneSettingDescription": "Delete messages older than 6 months from Communities that have over 2,000 messages.",
163+
"pruneSettingDescription": "Delete messages older than 12 months from Communities that have over 10,000 messages.",
164164
"enable": "Enable",
165165
"keepDisabled": "Keep disabled",
166166
"notificationSettingsDialog": "The information shown in notifications.",

ts/node/sql.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,9 +2220,9 @@ function cleanUpOldOpengroupsOnStart() {
22202220
return;
22212221
}
22222222
console.info(`Count of v2 opengroup convos to clean: ${v2ConvosIds.length}`);
2223-
// For each open group, if it has more than 2000 messages, we remove all the messages
2224-
// older than 6 months. So this does not limit the size of open group history to 2000
2225-
// messages but to 6 months.
2223+
// For each open group, if it has more than 10000 messages, we remove all the messages
2224+
// older than 12 months. So this does not limit the size of open group history to 10000
2225+
// messages but to 12 months.
22262226
//
22272227
// This is the only way we can clean up conversations objects from users which just
22282228
// sent messages a while ago and with whom we never interacted. This is only for open
@@ -2233,7 +2233,7 @@ function cleanUpOldOpengroupsOnStart() {
22332233
// Another fix would be to not cache all the conversations in the redux store, but it
22342234
// ain't going to happen any time soon as it would a pretty big change of the way we
22352235
// do things and would break a lot of the app.
2236-
const maxMessagePerOpengroupConvo = 2000;
2236+
const maxMessagePerOpengroupConvo = 10000;
22372237

22382238
// first remove very old messages for each opengroups
22392239
const db = assertGlobalInstance();
@@ -2244,7 +2244,8 @@ function cleanUpOldOpengroupsOnStart() {
22442244
if (messagesInConvoBefore >= maxMessagePerOpengroupConvo) {
22452245
const minute = 1000 * 60;
22462246
const sixMonths = minute * 60 * 24 * 30 * 6;
2247-
const limitTimestamp = Date.now() - sixMonths;
2247+
const twelveMonths = sixMonths * 2;
2248+
const limitTimestamp = Date.now() - twelveMonths;
22482249
const countToRemove = assertGlobalInstance()
22492250
.prepare(
22502251
`SELECT count(*) from ${MESSAGES_TABLE} WHERE serverTimestamp <= $serverTimestamp AND conversationId = $conversationId;`

0 commit comments

Comments
 (0)