Merge pull request #2902 from oxen-io/clearnet

Bump to 1.11.2
pull/3109/head
Audric Ackermann 2 years ago committed by GitHub
commit 712c5ff508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,11 @@ module.exports = {
root: true, root: true,
settings: { settings: {
'import/core-modules': ['electron'], 'import/core-modules': ['electron'],
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
react: { react: {
version: 'detect', version: 'detect',
}, },

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no -- commitlint --edit "$1"

@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Disabling this hook for now because the BuildLintCommand has issues. If you have an error in a file that eslint catches the commit fails silently instead of explaining the error (Will 04/09/2023)
# npx lint-staged

@ -0,0 +1,42 @@
const { ESLint } = require('eslint');
const removeIgnoredFiles = async files => {
const eslint = new ESLint();
const isIgnored = await Promise.all(
files.map(file => {
return eslint.isPathIgnored(file);
})
);
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
return filteredFiles.join(' ');
};
const buildFormatCommand = async files => {
const filesToLint = await removeIgnoredFiles(files);
if (!filesToLint || !filesToLint.length) {
return '';
}
const results = filesToLint.map(f => path.relative(process.cwd(), f));
return results.length
? `prettier --ignore-unknown --list-different --write ${results.join(' ')}`
: '';
};
const buildLintCommand = async files => {
const filesToLint = await removeIgnoredFiles(files);
if (!filesToLint || !filesToLint.length) {
return '';
}
const results = filesToLint.map(f => path.relative(process.cwd(), f));
return results.length ? `eslint --cache ${results.join(' ')}` : '';
};
module.exports = {
'*.{css,js,json,scss,ts,tsx}': [buildFormatCommand, buildLintCommand],
};

@ -37,3 +37,7 @@ Gruntfile.js
!istanbul-reports/lib/html/assets !istanbul-reports/lib/html/assets
!istanbul-api/node_modules/istanbul-reports/lib/html/assets !istanbul-api/node_modules/istanbul-reports/lib/html/assets
# lint-staged fix
# https://github.com/eemeli/yaml/issues/384#issuecomment-1368496106
!**/yaml/dist/**/doc

@ -129,6 +129,16 @@ Please write tests! Our testing framework is
The easiest way to run all tests at once is `yarn test`. The easiest way to run all tests at once is `yarn test`.
## Committing your changes
Before a commit is accepted the staged changes will be formatted using [prettier](https://prettier.io/) and linted using [eslint](https://eslint.org/). The commit will be reverted if files are formatted or lint errors are returned.
### Commit Message Convention
This project follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
Commit messages will be checked using [husky](https://typicode.github.io/husky/#/) and [commitlint](https://commitlint.js.org/).
## Pull requests ## Pull requests
So you wanna make a pull request? Please observe the following guidelines. So you wanna make a pull request? Please observe the following guidelines.

@ -12,6 +12,10 @@ Session integrates directly with [Oxen Service Nodes](https://docs.oxen.io/about
Please search for any [existing issues](https://github.com/oxen-io/session-desktop/issues) that describe your bug in order to avoid duplicate submissions. <br><br>Submissions can be made by making a pull request to our development branch.If you don't know where to start contributing please read [Contributing.md](CONTRIBUTING.md) and refer to issues tagged with the [Good-first-issue](https://github.com/oxen-io/session-desktop/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) tag. Please search for any [existing issues](https://github.com/oxen-io/session-desktop/issues) that describe your bug in order to avoid duplicate submissions. <br><br>Submissions can be made by making a pull request to our development branch.If you don't know where to start contributing please read [Contributing.md](CONTRIBUTING.md) and refer to issues tagged with the [Good-first-issue](https://github.com/oxen-io/session-desktop/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) tag.
## Supported platforms
Session requires Windows 10 or later, macOS Catalina (10.15) or later, or a linux distribution with glibc 2.28 or later like Debian 10 or Ubuntu 20.04.
## Build instruction ## Build instruction
Build instructions can be found in [Contributing.md](CONTRIBUTING.md). Build instructions can be found in [Contributing.md](CONTRIBUTING.md).

@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };

@ -2,7 +2,7 @@
"name": "session-desktop", "name": "session-desktop",
"productName": "Session", "productName": "Session",
"description": "Private messaging from your desktop", "description": "Private messaging from your desktop",
"version": "1.11.1", "version": "1.11.2",
"license": "GPL-3.0", "license": "GPL-3.0",
"author": { "author": {
"name": "Oxen Labs", "name": "Oxen Labs",
@ -64,7 +64,8 @@
"postinstall": "yarn patch-package && yarn electron-builder install-app-deps", "postinstall": "yarn patch-package && yarn electron-builder install-app-deps",
"update-git-info": "node ./build/updateLocalConfig.js", "update-git-info": "node ./build/updateLocalConfig.js",
"worker:utils": "webpack --config=./utils.worker.config.js", "worker:utils": "webpack --config=./utils.worker.config.js",
"worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js" "worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js",
"prepare": "husky install"
}, },
"dependencies": { "dependencies": {
"@emoji-mart/data": "^1.1.2", "@emoji-mart/data": "^1.1.2",
@ -132,6 +133,9 @@
"webrtc-adapter": "^4.1.1" "webrtc-adapter": "^4.1.1"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@commitlint/types": "^17.4.4",
"@electron/notarize": "^2.1.0", "@electron/notarize": "^2.1.0",
"@types/backbone": "1.4.2", "@types/backbone": "1.4.2",
"@types/blueimp-load-image": "5.14.4", "@types/blueimp-load-image": "5.14.4",
@ -182,8 +186,10 @@
"eslint-plugin-react": "^7.33.0", "eslint-plugin-react": "^7.33.0",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"events": "^3.3.0", "events": "^3.3.0",
"husky": "^8.0.0",
"jsdom": "^22.1.0", "jsdom": "^22.1.0",
"jsdom-global": "^3.0.2", "jsdom-global": "^3.0.2",
"lint-staged": "^14.0.1",
"mini-css-extract-plugin": "^2.7.5", "mini-css-extract-plugin": "^2.7.5",
"mocha": "10.0.0", "mocha": "10.0.0",
"node-loader": "^2.0.0", "node-loader": "^2.0.0",

@ -35,6 +35,7 @@ import { getAllCachedECKeyPair, sentAtMoreRecentThanWrapper } from './closedGrou
import { ConfigMessageHandler } from './configMessage'; import { ConfigMessageHandler } from './configMessage';
import { ECKeyPair } from './keypairs'; import { ECKeyPair } from './keypairs';
import { ContactsWrapperActions } from '../webworker/workers/browser/libsession_worker_interface'; import { ContactsWrapperActions } from '../webworker/workers/browser/libsession_worker_interface';
import { isUsFromCache } from '../session/utils/User';
export async function handleSwarmContentMessage(envelope: EnvelopePlus, messageHash: string) { export async function handleSwarmContentMessage(envelope: EnvelopePlus, messageHash: string) {
try { try {
@ -292,27 +293,42 @@ async function decrypt(envelope: EnvelopePlus): Promise<any> {
return plaintext; return plaintext;
} }
async function shouldDropIncomingPrivateMessage(sentAtTimestamp: number, envelope: EnvelopePlus) { async function shouldDropIncomingPrivateMessage(
sentAtTimestamp: number,
envelope: EnvelopePlus,
content: SignalService.Content
) {
// sentAtMoreRecentThanWrapper is going to be true, if the latest contact wrapper we processed was roughly more recent that this message timestamp // sentAtMoreRecentThanWrapper is going to be true, if the latest contact wrapper we processed was roughly more recent that this message timestamp
const moreRecentOrNah = await sentAtMoreRecentThanWrapper(sentAtTimestamp, 'ContactsConfig'); const moreRecentOrNah = await sentAtMoreRecentThanWrapper(sentAtTimestamp, 'ContactsConfig');
const isSyncedMessage = isUsFromCache(envelope.source);
if (moreRecentOrNah === 'wrapper_more_recent') { if (moreRecentOrNah === 'wrapper_more_recent') {
// we need to check if that conversation is already in the wrapper, and if yes // we need to check if that conversation is already in the wrapper
try { try {
const privateConvoInWrapper = await ContactsWrapperActions.get(envelope.source); // let's check if the corresponding conversation is hidden in the contacts wrapper or not.
// the corresponding conversation is syncTarget when this is a synced message only, so we need to rely on it first, then the envelope.source.
const syncTargetOrSource = isSyncedMessage
? content.dataMessage?.syncTarget || undefined
: envelope.source;
if (!syncTargetOrSource) {
return false;
}
const privateConvoInWrapper = await ContactsWrapperActions.get(syncTargetOrSource);
if ( if (
!privateConvoInWrapper || !privateConvoInWrapper ||
privateConvoInWrapper.priority <= CONVERSATION_PRIORITIES.hidden privateConvoInWrapper.priority <= CONVERSATION_PRIORITIES.hidden
) { ) {
// the wrapper is more recent that this message and there is no such private conversation. Just drop this incoming message. // the wrapper is more recent that this message and there is no such private conversation. Just drop this incoming message.
window.log.info( window.log.info(
`received message from contact ${envelope.source} which appears to be hidden/removed in our most recent libsession contactconfig, sentAt: ${sentAtTimestamp}. Dropping it` `received message on conversation ${syncTargetOrSource} which appears to be hidden/removed in our most recent libsession contactconfig, sentAt: ${sentAtTimestamp}. Dropping it`
); );
return true; return true;
} }
window.log.info( window.log.info(
`received message from contact ${envelope.source} which appears to NOT be hidden/removed in our most recent libsession contactconfig, sentAt: ${sentAtTimestamp}. ` `received message on conversation ${syncTargetOrSource} which appears to NOT be hidden/removed in our most recent libsession contactconfig, sentAt: ${sentAtTimestamp}. `
); );
} catch (e) { } catch (e) {
window.log.warn( window.log.warn(
@ -409,7 +425,7 @@ export async function innerHandleSwarmContentMessage(
const isPrivateConversationMessage = !envelope.senderIdentity; const isPrivateConversationMessage = !envelope.senderIdentity;
if (isPrivateConversationMessage) { if (isPrivateConversationMessage) {
if (await shouldDropIncomingPrivateMessage(sentAtTimestamp, envelope)) { if (await shouldDropIncomingPrivateMessage(sentAtTimestamp, envelope, content)) {
await removeFromCache(envelope); await removeFromCache(envelope);
return; return;
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save