updating workflows actions version
This commit is contained in:
parent
4010373a7b
commit
0efce6ea2d
|
@ -3,9 +3,6 @@ components/**
|
||||||
dist/**
|
dist/**
|
||||||
mnemonic_languages/**
|
mnemonic_languages/**
|
||||||
|
|
||||||
# Generated files
|
|
||||||
js/util_worker.js
|
|
||||||
|
|
||||||
# TypeScript generated files
|
# TypeScript generated files
|
||||||
ts/**/*.js
|
ts/**/*.js
|
||||||
**/ts/**/*.js
|
**/ts/**/*.js
|
||||||
|
|
|
@ -20,13 +20,23 @@ jobs:
|
||||||
SIGNAL_ENV: production
|
SIGNAL_ENV: production
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout git repo
|
- run: git config --global core.autocrlf false
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
|
- name: Checkout git repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# we stay on v2 even if there is a v3 because the v3 logic is less flexible for our usecase
|
||||||
- name: Install node
|
- name: Install node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.13.0
|
node-version: '16.13.0'
|
||||||
|
|
||||||
|
- name: Cache Desktop node_modules
|
||||||
|
id: cache-desktop-modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock', 'patches/**') }}
|
||||||
|
|
||||||
- name: Chocolatey Install Action
|
- name: Chocolatey Install Action
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
@ -34,8 +44,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
args: install python2 visualcpp-build-tools -y
|
args: install python2 visualcpp-build-tools -y
|
||||||
|
|
||||||
|
# Not having this will break the windows build because the PATH won't be set by msbuild.
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.0.2
|
uses: microsoft/setup-msbuild@v1.1
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
|
||||||
- name: Setup node for windows
|
- name: Setup node for windows
|
||||||
|
@ -45,19 +56,21 @@ jobs:
|
||||||
npm config set python python2.7
|
npm config set python python2.7
|
||||||
npm config set msvs_version 2017
|
npm config set msvs_version 2017
|
||||||
|
|
||||||
- name: Install yarn
|
- name: Install Desktop node_modules
|
||||||
run: npm install yarn --no-save
|
if: steps.cache-desktop-modules.outputs.cache-hit != 'true'
|
||||||
|
run: yarn install --frozen-lockfile --network-timeout 600000 --force
|
||||||
- name: Install Dependencies
|
|
||||||
run: yarn install --frozen-lockfile --network-timeout 600000
|
|
||||||
|
|
||||||
- name: Generate and concat files
|
- name: Generate and concat files
|
||||||
run: yarn generate
|
run: yarn generate && yarn transpile
|
||||||
|
|
||||||
- name: Lint Files
|
- name: Lint Files
|
||||||
if: runner.os != 'Windows'
|
# no need to lint files on all platforms. Just do it once on the quicker one
|
||||||
|
if: runner.os == 'Linux'
|
||||||
run: yarn lint-full
|
run: yarn lint-full
|
||||||
|
|
||||||
|
- name: Unit Test
|
||||||
|
run: yarn test
|
||||||
|
|
||||||
- name: Build windows production binaries
|
- name: Build windows production binaries
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
run: node_modules\.bin\electron-builder --config.extraMetadata.environment=%SIGNAL_ENV% --publish=never --config.directories.output=release
|
run: node_modules\.bin\electron-builder --config.extraMetadata.environment=%SIGNAL_ENV% --publish=never --config.directories.output=release
|
||||||
|
|
|
@ -20,12 +20,20 @@ jobs:
|
||||||
- run: git config --global core.autocrlf false
|
- run: git config --global core.autocrlf false
|
||||||
|
|
||||||
- name: Checkout git repo
|
- name: Checkout git repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# we stay on v2 even if there is a v3 because the v3 logic is less flexible for our usecase
|
||||||
- name: Install node
|
- name: Install node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.13.0
|
node-version: '16.13.0'
|
||||||
|
|
||||||
|
- name: Cache Desktop node_modules
|
||||||
|
id: cache-desktop-modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock', 'patches/**') }}
|
||||||
|
|
||||||
- name: Chocolatey Install Action
|
- name: Chocolatey Install Action
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
@ -35,7 +43,7 @@ jobs:
|
||||||
|
|
||||||
#Not having this will break the windows build because the PATH won't be set by msbuild.
|
#Not having this will break the windows build because the PATH won't be set by msbuild.
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.0.2
|
uses: microsoft/setup-msbuild@v1.1
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
|
||||||
- name: Setup node for windows
|
- name: Setup node for windows
|
||||||
|
@ -45,38 +53,17 @@ jobs:
|
||||||
npm config set python python2.7
|
npm config set python python2.7
|
||||||
npm config set msvs_version 2017
|
npm config set msvs_version 2017
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- name: Install Desktop node_modules
|
||||||
id: yarn-cache
|
if: steps.cache-desktop-modules.outputs.cache-hit != 'true'
|
||||||
if: runner.os != 'Windows'
|
run: yarn install --frozen-lockfile --network-timeout 600000 --force
|
||||||
with:
|
|
||||||
path: '**/node_modules'
|
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Install Dependencies #skipped if step before set variable to true
|
|
||||||
if: |
|
|
||||||
steps.yarn-cache.outputs.cache-hit != 'true'
|
|
||||||
run: yarn install --frozen-lockfile --network-timeout 600000
|
|
||||||
|
|
||||||
- name: Generate and concat files
|
- name: Generate and concat files
|
||||||
run: yarn generate
|
run: yarn generate && yarn transpile
|
||||||
|
|
||||||
- name: Lint Files
|
- name: Lint Files
|
||||||
if: runner.os != 'Windows'
|
# no need to lint files on all platforms. Just do it once on the quicker one
|
||||||
run: |
|
|
||||||
yarn lint-full
|
|
||||||
|
|
||||||
- name: Make linux use en_US locale
|
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: yarn lint-full
|
||||||
sudo apt-get install -y hunspell-en-us
|
|
||||||
sudo locale-gen en_US.UTF-8
|
|
||||||
sudo dpkg-reconfigure locales
|
|
||||||
echo "::stop-commands::`echo -n ${{ github.token }} | sha256sum | head -c 64`"
|
|
||||||
echo ::set-env name=DISPLAY:::9.0
|
|
||||||
echo ::set-env name=LANG::en_US.UTF-8
|
|
||||||
echo "::`echo -n ${{ github.token }} | sha256sum | head -c 64`::"
|
|
||||||
|
|
||||||
- name: Test
|
- name: Unit Test
|
||||||
uses: GabrielBB/xvfb-action@v1.0
|
run: yarn test
|
||||||
with:
|
|
||||||
run: yarn test
|
|
||||||
|
|
|
@ -17,13 +17,23 @@ jobs:
|
||||||
SIGNAL_ENV: production
|
SIGNAL_ENV: production
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout git repo
|
- run: git config --global core.autocrlf false
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
|
- name: Checkout git repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# we stay on v2 even if there is a v3 because the v3 logic is less flexible for our usecase
|
||||||
- name: Install node
|
- name: Install node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.13.0
|
node-version: '16.13.0'
|
||||||
|
|
||||||
|
- name: Cache Desktop node_modules
|
||||||
|
id: cache-desktop-modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock', 'patches/**') }}
|
||||||
|
|
||||||
- name: Chocolatey Install Action
|
- name: Chocolatey Install Action
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
@ -31,8 +41,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
args: install python2 visualcpp-build-tools -y
|
args: install python2 visualcpp-build-tools -y
|
||||||
|
|
||||||
|
#Not having this will break the windows build because the PATH won't be set by msbuild.
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.0.2
|
uses: microsoft/setup-msbuild@v1.1
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
|
||||||
- name: Setup node for windows
|
- name: Setup node for windows
|
||||||
|
@ -42,20 +53,21 @@ jobs:
|
||||||
npm config set python python2.7
|
npm config set python python2.7
|
||||||
npm config set msvs_version 2017
|
npm config set msvs_version 2017
|
||||||
|
|
||||||
- name: Install yarn
|
- name: Install Desktop node_modules
|
||||||
run: npm install yarn --no-save
|
if: steps.cache-desktop-modules.outputs.cache-hit != 'true'
|
||||||
|
run: yarn install --frozen-lockfile --network-timeout 600000 --force
|
||||||
- name: Install Dependencies
|
|
||||||
run: yarn install --frozen-lockfile --network-timeout 600000
|
|
||||||
|
|
||||||
- name: Generate and concat files
|
- name: Generate and concat files
|
||||||
run: yarn generate
|
run: yarn generate && yarn transpile
|
||||||
|
|
||||||
- name: Lint Files
|
- name: Lint Files
|
||||||
# no need to lint files on all platforms. Just do it once on the quicker one
|
# no need to lint files on all platforms. Just do it once on the quicker one
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: yarn lint-full
|
run: yarn lint-full
|
||||||
|
|
||||||
|
- name: Unit Test
|
||||||
|
run: yarn test
|
||||||
|
|
||||||
- name: Build windows production binaries
|
- name: Build windows production binaries
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
run: node_modules\.bin\electron-builder --config.extraMetadata.environment=%SIGNAL_ENV% --publish=always
|
run: node_modules\.bin\electron-builder --config.extraMetadata.environment=%SIGNAL_ENV% --publish=always
|
||||||
|
|
|
@ -13,7 +13,6 @@ release/
|
||||||
sql/
|
sql/
|
||||||
|
|
||||||
# generated files
|
# generated files
|
||||||
js/util_worker.js
|
|
||||||
stylesheets/*.css
|
stylesheets/*.css
|
||||||
|
|
||||||
# React / TypeScript
|
# React / TypeScript
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
config/local-*.json
|
config/local-*.json
|
||||||
config/local.json
|
config/local.json
|
||||||
dist/**
|
dist/**
|
||||||
js/util_worker.js
|
|
||||||
stylesheets/*.css
|
stylesheets/*.css
|
||||||
|
|
||||||
test/ts/**/*.js
|
test/ts/**/*.js
|
||||||
|
@ -18,7 +17,6 @@ ts/test/automation/notes
|
||||||
|
|
||||||
# Third-party files
|
# Third-party files
|
||||||
node_modules/**
|
node_modules/**
|
||||||
js/util_worker.js
|
|
||||||
mnemonic_languages/**
|
mnemonic_languages/**
|
||||||
playwright.config.js
|
playwright.config.js
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,10 @@ module.exports = async function(context) {
|
||||||
const targetExecutable = path.join(context.appOutDir, `${executableName}-bin`);
|
const targetExecutable = path.join(context.appOutDir, `${executableName}-bin`);
|
||||||
const launcherScript = path.join(context.appOutDir, 'resources', 'launcher-script.sh');
|
const launcherScript = path.join(context.appOutDir, 'resources', 'launcher-script.sh');
|
||||||
const chromeSandbox = path.join(context.appOutDir, 'chrome-sandbox');
|
const chromeSandbox = path.join(context.appOutDir, 'chrome-sandbox');
|
||||||
|
// rename session-desktop to session-desktop-bin
|
||||||
return Promise.all([
|
await renameAsync(sourceExecutable, targetExecutable);
|
||||||
// rename session-desktop to session-desktop-bin
|
// rename launcher script to session-desktop
|
||||||
renameAsync(sourceExecutable, targetExecutable),
|
await renameAsync(launcherScript, sourceExecutable);
|
||||||
|
// remove the chrome-sandbox file since we explicitly disable it
|
||||||
// rename launcher script to session-desktop
|
return unlinkAsync(chromeSandbox);
|
||||||
renameAsync(launcherScript, sourceExecutable),
|
|
||||||
|
|
||||||
// remove the chrome-sandbox file since we explicitly disable it
|
|
||||||
unlinkAsync(chromeSandbox),
|
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|
12
package.json
12
package.json
|
@ -49,7 +49,7 @@
|
||||||
"ready": "yarn grunt && yarn lint-full && yarn test",
|
"ready": "yarn grunt && yarn lint-full && yarn test",
|
||||||
"sedtoAppImage": "sed -i 's/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/\"target\": \"AppImage\"/g' package.json",
|
"sedtoAppImage": "sed -i 's/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/\"target\": \"AppImage\"/g' package.json",
|
||||||
"sedtoDeb": "sed -i 's/\"target\": \"AppImage\"/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/g' package.json",
|
"sedtoDeb": "sed -i 's/\"target\": \"AppImage\"/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/g' package.json",
|
||||||
"parcel-util-worker": "rimraf ts/webworker/workers/util.worker.js; parcel build --target util-worker --no-autoinstall --no-cache"
|
"parcel-util-worker": "rimraf ts/webworker/workers/util.worker.js && parcel build --target util-worker --no-autoinstall --no-cache"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@reduxjs/toolkit": "^1.4.0",
|
"@reduxjs/toolkit": "^1.4.0",
|
||||||
|
@ -122,10 +122,6 @@
|
||||||
"styled-components": "5.1.1",
|
"styled-components": "5.1.1",
|
||||||
"uuid": "3.3.2"
|
"uuid": "3.3.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
|
||||||
"react": "^17.0.2",
|
|
||||||
"react-dom": "^17.0.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.16.3",
|
"@playwright/test": "^1.16.3",
|
||||||
"@types/backbone": "^1.4.2",
|
"@types/backbone": "^1.4.2",
|
||||||
|
@ -225,6 +221,7 @@
|
||||||
"build": {
|
"build": {
|
||||||
"appId": "com.loki-project.messenger-desktop",
|
"appId": "com.loki-project.messenger-desktop",
|
||||||
"afterSign": "build/notarize.js",
|
"afterSign": "build/notarize.js",
|
||||||
|
"afterPack": "build/afterPackHook.js",
|
||||||
"artifactName": "${name}-${os}-${arch}-${version}.${ext}",
|
"artifactName": "${name}-${os}-${arch}-${version}.${ext}",
|
||||||
"extraResources": {
|
"extraResources": {
|
||||||
"from": "./build/launcher-script.sh",
|
"from": "./build/launcher-script.sh",
|
||||||
|
@ -344,11 +341,12 @@
|
||||||
"!node_modules/@journeyapps/sqlcipher/build/*",
|
"!node_modules/@journeyapps/sqlcipher/build/*",
|
||||||
"!node_modules/@journeyapps/sqlcipher/lib/binding/node-*",
|
"!node_modules/@journeyapps/sqlcipher/lib/binding/node-*",
|
||||||
"!build/*.js",
|
"!build/*.js",
|
||||||
|
"build/afterPackHook.js",
|
||||||
|
"build/launcher-script.sh",
|
||||||
"!node_modules/better-sqlite3/deps/*",
|
"!node_modules/better-sqlite3/deps/*",
|
||||||
"!node_modules/better-sqlite3/src/*",
|
"!node_modules/better-sqlite3/src/*",
|
||||||
"node_modules/better-sqlite3/build/Release/better_sqlite3.node",
|
"node_modules/better-sqlite3/build/Release/better_sqlite3.node",
|
||||||
"!dev-app-update.yml"
|
"!dev-app-update.yml"
|
||||||
],
|
]
|
||||||
"afterPack": "./build/afterPackHook.js"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,28 +132,6 @@ export const SettingsCategoryAppearance = (props: { hasPassword: boolean | null
|
||||||
buttonColor={SessionButtonColor.Primary}
|
buttonColor={SessionButtonColor.Primary}
|
||||||
buttonText={window.i18n('translation')}
|
buttonText={window.i18n('translation')}
|
||||||
/>
|
/>
|
||||||
{/* <SessionSettingButtonItem
|
|
||||||
title={window.i18n('trimDatabase')}
|
|
||||||
description={window.i18n('trimDatabaseDescription')}
|
|
||||||
onClick={async () => {
|
|
||||||
const msgCount = await getMessageCount();
|
|
||||||
const deleteAmount = Math.max(msgCount - 10000, 0);
|
|
||||||
|
|
||||||
dispatch(
|
|
||||||
updateConfirmModal({
|
|
||||||
onClickOk: () => {
|
|
||||||
void trimMessages();
|
|
||||||
},
|
|
||||||
onClickClose: () => {
|
|
||||||
updateConfirmModal(null);
|
|
||||||
},
|
|
||||||
message: window.i18n('trimDatabaseConfirmationBody', [`${deleteAmount}`]),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
buttonColor={SessionButtonColor.Primary}
|
|
||||||
buttonText={window.i18n('trimDatabase')}
|
|
||||||
/> */}
|
|
||||||
<SessionSettingButtonItem
|
<SessionSettingButtonItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
ipcRenderer.send('show-debug-log');
|
ipcRenderer.send('show-debug-log');
|
||||||
|
|
|
@ -551,11 +551,6 @@ export async function removeAllMessagesInConversation(conversationId: string): P
|
||||||
} while (messages.length > 0);
|
} while (messages.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function trimMessages(): Promise<void> {
|
|
||||||
await channels.trimMessages(1000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getMessagesBySentAt(sentAt: number): Promise<MessageCollection> {
|
export async function getMessagesBySentAt(sentAt: number): Promise<MessageCollection> {
|
||||||
const messages = await channels.getMessagesBySentAt(sentAt);
|
const messages = await channels.getMessagesBySentAt(sentAt);
|
||||||
return new MessageCollection(messages);
|
return new MessageCollection(messages);
|
||||||
|
|
|
@ -64,7 +64,6 @@ const channelsToMake = new Set([
|
||||||
'hasConversationOutgoingMessage',
|
'hasConversationOutgoingMessage',
|
||||||
'getSeenMessagesByHashList',
|
'getSeenMessagesByHashList',
|
||||||
'getLastHashBySnode',
|
'getLastHashBySnode',
|
||||||
'trimMessages',
|
|
||||||
'getUnprocessedCount',
|
'getUnprocessedCount',
|
||||||
'getAllUnprocessed',
|
'getAllUnprocessed',
|
||||||
'getUnprocessedById',
|
'getUnprocessedById',
|
||||||
|
|
130
ts/node/sql.ts
130
ts/node/sql.ts
|
@ -2558,135 +2558,6 @@ function getFirstUnreadMessageWithMention(conversationId: string, ourpubkey: str
|
||||||
return rows[0].id;
|
return rows[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes all but the 10,000 last received messages.
|
|
||||||
*/
|
|
||||||
function trimMessages(limit: number) {
|
|
||||||
console.log(limit); // adding this for linting purposes.
|
|
||||||
// METHOD 1 Start - Seems to take to long and freeze
|
|
||||||
// const convoCount = globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// SELECT COUNT(*) FROM ${MESSAGES_TABLE}
|
|
||||||
// WHERE conversationId = $conversationId
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .all({
|
|
||||||
// conversationId,
|
|
||||||
// });
|
|
||||||
// if (convoCount < limit) {
|
|
||||||
// console.log(`Skipping conversation: ${conversationId}`);
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// console.count('convo surpassed limit');
|
|
||||||
// }
|
|
||||||
// globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// DELETE FROM ${MESSAGES_TABLE}
|
|
||||||
// WHERE conversationId = $conversationId
|
|
||||||
// AND id NOT IN (
|
|
||||||
// SELECT id FROM ${MESSAGES_TABLE}
|
|
||||||
// WHERE conversationId = $conversationId
|
|
||||||
// ORDER BY received_at DESC
|
|
||||||
// LIMIT $limit
|
|
||||||
// );
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .run({
|
|
||||||
// conversationId,
|
|
||||||
// limit,
|
|
||||||
// });
|
|
||||||
// METHOD 1 END
|
|
||||||
// METHOD 2 Start
|
|
||||||
// const messages = globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// SELECT id, conversationId FROM ${MESSAGES_TABLE}
|
|
||||||
// CREATE VIRTUAL TABLE IF NOT EXISTS temp_deletion
|
|
||||||
// id STRING PRIMARY KEY ASC
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .all();
|
|
||||||
// const idsToDelete = [];
|
|
||||||
// const convoCountLookup = {};
|
|
||||||
// for (let index = 0; index < messages.length; index + 1) {
|
|
||||||
// const { conversationId, id } = messages[index];
|
|
||||||
// console.log(`run ${index} - convoId: ${conversationId}, messageId: ${id}`);
|
|
||||||
// if (!convoCountLookup[conversationId]) {
|
|
||||||
// convoCountLookup[conversationId] = 1;
|
|
||||||
// } else {
|
|
||||||
// convoCountLookup[conversationId] + 1;
|
|
||||||
// if (convoCountLookup[conversationId] > limit) {
|
|
||||||
// idsToDelete.push(id);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // Ideally should be able to do WHERE id IN (x, y, z) with an array of IDs
|
|
||||||
// // the array might need to be chunked as well for performance
|
|
||||||
// const idSlice = [...idsToDelete].slice(0, 30);
|
|
||||||
// idSlice.forEach(() => {
|
|
||||||
// globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// DELETE FROM ${MESSAGES_TABLE}
|
|
||||||
// WHERE id = $idSlice
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .run({
|
|
||||||
// idSlice,
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// Method 2 End
|
|
||||||
// Method 3 start - Audric's suggestion
|
|
||||||
// const largeConvos = globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// SELECT conversationId, count(id) FROM ${MESSAGES_TABLE}
|
|
||||||
// GROUP BY conversationId
|
|
||||||
// HAVING COUNT(id) > 1000
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .all();
|
|
||||||
// console.log({ largeConvos });
|
|
||||||
// // finding 1000th msg timestamp
|
|
||||||
// largeConvos.forEach(convo => {
|
|
||||||
// const convoId = convo.conversationId;
|
|
||||||
// console.log({ convoId });
|
|
||||||
// const lastMsg = globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// SELECT received_at, sent_at FROM ${MESSAGES_TABLE}
|
|
||||||
// WHERE conversationId = $convoId
|
|
||||||
// ORDER BY received_at DESC
|
|
||||||
// LIMIT 1
|
|
||||||
// OFFSET 999
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .all({
|
|
||||||
// convoId,
|
|
||||||
// });
|
|
||||||
// // use timestamp with lesserThan as conditional for deletion
|
|
||||||
// console.log({ lastMsg });
|
|
||||||
// const timestamp = lastMsg[0].received_at;
|
|
||||||
// if (timestamp) {
|
|
||||||
// console.log({ timestamp, convoId });
|
|
||||||
// globalInstance
|
|
||||||
// .prepare(
|
|
||||||
// `
|
|
||||||
// DELETE FROM ${MESSAGES_TABLE}
|
|
||||||
// WHERE conversationId = $convoId
|
|
||||||
// AND received_at < $timestamp
|
|
||||||
// `
|
|
||||||
// )
|
|
||||||
// .run({
|
|
||||||
// timestamp,
|
|
||||||
// convoId,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMessagesBySentAt(sentAt: number) {
|
function getMessagesBySentAt(sentAt: number) {
|
||||||
const rows = assertGlobalInstance()
|
const rows = assertGlobalInstance()
|
||||||
.prepare(
|
.prepare(
|
||||||
|
@ -3783,7 +3654,6 @@ export const sqlNode = {
|
||||||
getFirstUnreadMessageIdInConversation,
|
getFirstUnreadMessageIdInConversation,
|
||||||
getFirstUnreadMessageWithMention,
|
getFirstUnreadMessageWithMention,
|
||||||
hasConversationOutgoingMessage,
|
hasConversationOutgoingMessage,
|
||||||
trimMessages,
|
|
||||||
fillWithTestData,
|
fillWithTestData,
|
||||||
|
|
||||||
getUnprocessedCount,
|
getUnprocessedCount,
|
||||||
|
|
|
@ -87,13 +87,19 @@ describe('Privacy', () => {
|
||||||
it('removes whatever is in front of the app root path before logging', () => {
|
it('removes whatever is in front of the app root path before logging', () => {
|
||||||
const appRootPath = path.join(__dirname, '..', '..', '..', '..', '..');
|
const appRootPath = path.join(__dirname, '..', '..', '..', '..', '..');
|
||||||
const appFolderName = path.basename(appRootPath);
|
const appFolderName = path.basename(appRootPath);
|
||||||
expect(redactAll(appRootPath)).to.be.equal(`[REDACTED]/${appFolderName}`);
|
expect(redactAll(appRootPath)).to.be.be.oneOf([
|
||||||
|
`[REDACTED]/${appFolderName}`,
|
||||||
|
`[REDACTED]\\${appFolderName}`,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes whatever is in front of the app root path before logging', () => {
|
it('removes whatever is in front of the app root path before logging', () => {
|
||||||
const appRootPath = path.join(__dirname, '..', '..', '..', '..', '..');
|
const appRootPath = path.join(__dirname, '..', '..', '..', '..', '..');
|
||||||
const appFolderName = path.basename(appRootPath);
|
const appFolderName = path.basename(appRootPath);
|
||||||
expect(redactAll(appRootPath)).to.be.equal(`[REDACTED]/${appFolderName}`);
|
expect(redactAll(appRootPath)).to.be.be.oneOf([
|
||||||
|
`[REDACTED]/${appFolderName}`,
|
||||||
|
`[REDACTED]\\${appFolderName}`,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue