Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed group chunk1 #2873

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
53fca2a
fix: text for note to self delete from all my devices
Bilb Aug 21, 2023
5b2580c
feat: add poller changes and closed group keypair gen
Bilb Aug 23, 2023
db98cc2
feat: able to create a broken closedgroup v3
Bilb Sep 7, 2023
f23c525
feat: add protobuf changes for new groups
Bilb Sep 7, 2023
a7acba8
chore: cleanup protobuf to spaces indent
Bilb Sep 7, 2023
8c3b650
fix: wip before removing info+members+keys from protobuf kinds
Bilb Sep 11, 2023
4291337
fix: remove groups from protobuf
Bilb Sep 11, 2023
f86b368
fix: add GroupSyncJob to push changes for group
Bilb Sep 12, 2023
d89ff59
feat: store info+members+keys on right namespaces for groups
Bilb Sep 13, 2023
be50aa7
feat: add support for retrieve signs with admin key of group
Bilb Sep 13, 2023
90f4dd7
feat: add meta merge and update of name+members
Bilb Sep 14, 2023
08164f2
feat: add sending and receiving of libsession encrypted msgs
Bilb Sep 15, 2023
bbedfd9
fix: do not confirm keys once pushed, wait for poll event
Bilb Sep 18, 2023
46e3675
feat: add function to redux to grab group detail outside of store
Bilb Sep 19, 2023
197383a
feat: move some the convomodel.get attributes to functions
Bilb Sep 19, 2023
9191c34
feat: mark us as admin and others as invite pending
Bilb Sep 19, 2023
1a18054
feat: add bump of config hashes for groups when we have admin key
Bilb Sep 20, 2023
cd17a08
chore: lint
Bilb Sep 20, 2023
b532645
feat: preload name of group from usergroup wrapper
Bilb Sep 21, 2023
e220aee
feat: add working encrypt/decrypt for 03 group with libsession
Bilb Sep 21, 2023
1dc5224
test: added unit tests for pubkeys constructor checks
Bilb Sep 21, 2023
820103b
chore: refactor snodesignature input args type
Bilb Sep 21, 2023
e8e0e19
chore: added tests for SnodeSignatures calls
Bilb Sep 22, 2023
d12071f
chore: big rename of convocontroller to convohub
Bilb Sep 26, 2023
e69c5c4
chore: fixed unit tests
Bilb Sep 27, 2023
cc7e6f0
test: add tests for swarmPolling of new groups 03
Bilb Sep 27, 2023
9cf5d4d
test: add unit tests for encrypting/decryption groups messages
Bilb Oct 2, 2023
cf44ea1
test: added tests for group info get/set
Bilb Oct 2, 2023
e24ec9e
test: added tests for metagroup members wrapper
Bilb Oct 3, 2023
6b3adff
test: added a (still broken) test for key conflicts
Bilb Oct 3, 2023
5120542
test: add tests for GroupSyncJob
Bilb Oct 9, 2023
0ef2df8
test: speedup onion tests by stubbing retries timeout
Bilb Oct 9, 2023
d9300e6
fix: remove the whole kind logic and use namespace instead
Bilb Oct 10, 2023
c142762
chore: merged what can be between user and group sync job
Bilb Oct 10, 2023
eb77c50
chore: renamed GroupConfigurationJob to GroupSyncJob
Bilb Oct 11, 2023
d134da3
chore: renamed ConfigurationSyncJob to UserSyncJob
Bilb Oct 11, 2023
ceffa1e
test: add tests for pendingchangesforus
Bilb Oct 11, 2023
9492fdc
fix: first working test ios to desktop
Bilb Oct 12, 2023
ae67215
test: finished tests for userSyncJob
Bilb Oct 12, 2023
2ee4cad
chore: move mocha config to .mocharc.yml to package.json is cleaner
Bilb Oct 13, 2023
8445139
Merge remote-tracking branch 'upstream/unstable' into closed-group-ch…
Bilb Oct 13, 2023
b0e3867
chore: rename all groupv3 to groupv2
Bilb Oct 15, 2023
0b4f9b2
chore: rename useSelectedisNoteToSelf to useSelectedIsNoteToSelf
Bilb Oct 15, 2023
28d99a0
chore: lint
Bilb Oct 16, 2023
ed16e9b
Merge remote-tracking branch 'upstream/unstable' into closed-group-ch…
Bilb Oct 17, 2023
df3a188
fix: address PR reviews
Bilb Oct 17, 2023
4668e07
fix: address PR reviews
Bilb Oct 27, 2023
c1c6fae
chore: use release from libsession-nodejs 0.4.0
Bilb Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var path = require('path');

module.exports = {
root: true,
settings: {
Expand All @@ -10,6 +12,11 @@ module.exports = {
react: {
version: 'detect',
},
'import/resolver': {
node: {
paths: [path.resolve(__dirname)],
},
},
},

extends: [
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ test-results/
coverage/
stylesheets/dist/

*.worker.js.LICENSE.txt
*.LICENSE.txt
ts/webworker/workers/node/**/*.node
11 changes: 11 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
jobs: 1
package: './package.json'
parallel: false
exit: true
recursive: true
require: 'jsdom-global/register'
sort: false
spec:
- './ts/test/**/*_test.js' # the positional arguments!
timeout: 1000
watch: false
1 change: 1 addition & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"delete": "Delete",
"messageDeletionForbidden": "You don’t have permission to delete others’ messages",
"deleteJustForMe": "Delete just for me",
"deleteFromAllMyDevices": "Delete from all my devices",
"deleteForEveryone": "Delete for everyone",
"deleteMessagesQuestion": "Delete $count$ messages?",
"deleteMessageQuestion": "Delete this message?",
Expand Down
2 changes: 1 addition & 1 deletion build/afterPackHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const util = require('util');
const renameAsync = util.promisify(fs.rename);
const unlinkAsync = util.promisify(fs.unlink);

module.exports = async function(context) {
module.exports = async function (context) {
// Replace the app launcher on linux only.
if (process.platform !== 'linux') {
return;
Expand Down
2 changes: 1 addition & 1 deletion js/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"env": {
"browser": true,
"node": false
"node": true
},
"parserOptions": {
"sourceType": "script"
Expand Down
6 changes: 4 additions & 2 deletions libsession.worker.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');

const isProd = process.env.NODE_ENV === 'production';

module.exports = {
entry: './ts/webworker/workers/node/libsession/libsession.worker.ts',
node: {
Expand Down Expand Up @@ -29,11 +31,11 @@ module.exports = {
},
},
output: {
filename: 'libsession.worker.js',
filename: 'libsession.worker.compiled.js',
path: path.resolve(__dirname, 'ts', 'webworker', 'workers', 'node', 'libsession'),
},
target: 'node',
optimization: {
minimize: true,
minimize: isProd,
},
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lint-full": "yarn format-full && eslint .",
"format-full": "prettier --list-different --write \"*.{css,js,json,scss,ts,tsx}\" \"./**/*.{css,js,json,scss,ts,tsx}\"",
"start-prod-test": "cross-env NODE_ENV=production NODE_APP_INSTANCE=$MULTI electron .",
"test": "mocha -r jsdom-global/register --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\"",
"test": "mocha",
yougotwill marked this conversation as resolved.
Show resolved Hide resolved
"build-release": "run-script-os",
"build-release-non-linux": "yarn build-everything && cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release",
"build-release:win32": "yarn build-release-non-linux",
Expand Down Expand Up @@ -95,7 +95,7 @@
"glob": "7.1.2",
"image-type": "^4.1.0",
"ip2country": "1.0.1",
"libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.2.6/libsession_util_nodejs-v0.2.6.tar.gz",
"libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.4.0/libsession_util_nodejs-v0.4.0.tar.gz",
"libsodium-wrappers-sumo": "^0.7.9",
"linkify-it": "^4.0.1",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -195,7 +195,7 @@
"node-loader": "^2.0.0",
"patch-package": "^6.4.7",
"postinstall-prepare": "^1.0.1",
"prettier": "1.19.0",
"prettier": "^3.0.3",
"protobufjs-cli": "^1.1.1",
"run-script-os": "^1.1.6",
"sass": "^1.60.0",
Expand Down
7 changes: 4 additions & 3 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ window.sessionFeatureFlags = {
integrationTestEnv: Boolean(
process.env.NODE_APP_INSTANCE && process.env.NODE_APP_INSTANCE.includes('test-integration')
),
useClosedGroupV3: false || process.env.USE_CLOSED_GROUP_V3,
useClosedGroupV2: true, // TODO DO NOT MERGE Remove after QA
debug: {
debugLogging: !_.isEmpty(process.env.SESSION_DEBUG),
debugLibsessionDumps: !_.isEmpty(process.env.SESSION_DEBUG_LIBSESSION_DUMPS),
Expand Down Expand Up @@ -239,8 +239,9 @@ const data = require('./ts/data/dataInit');
const { setupi18n } = require('./ts/util/i18n');
window.Signal = data.initData();

const { getConversationController } = require('./ts/session/conversations/ConversationController');
window.getConversationController = getConversationController;
const { ConvoHub } = require('./ts/session/conversations/ConversationController');
window.getConversationController = ConvoHub.use;

// Linux seems to periodically let the event loop stop, so this is a global workaround
setInterval(() => {
window.nodeSetImmediate(() => {});
Expand Down
38 changes: 0 additions & 38 deletions protos/SignalService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ message SharedConfigMessage {
CONTACTS = 2;
CONVO_INFO_VOLATILE = 3;
USER_GROUPS = 4;
// CLOSED_GROUP_INFO = 5;
// CLOSED_GROUP_MEMBERS = 6;
// ENCRYPTION_KEYS = 7;
}

required Kind kind = 1;
Expand Down Expand Up @@ -85,41 +82,7 @@ message DataExtractionNotification {
optional uint64 timestamp = 2;
}

// message GroupInviteMessage {
// required string name = 1;
// required bytes memberPrivateKey = 2;
// }

// this will replace our closedGroupControlMessage but we will need to keep both for some time
// message GroupMessage {
// optional GroupAdminMessage adminMessage = 31;
// optional GroupMemberLeftMessage memberLeftMessage = 32;
// optional GroupInviteMessage inviteMessage = 33;
// optional GroupPromoteMessage promoteMessage = 34;
// }

// message GroupPromoteMessage {
// required bytes privateKey = 1; // this is the group admins key
// }

// message GroupAdminMessage {
// enum Type {
// DELETE_GROUP = 1; // members, groupSignature
// DELETE_GROUP_ALL_MEMBERS = 2; // groupSignature
// DELETE_MESSAGES_ALL_MEMBERS = 3; // groupSignature
// DELETE_ATTACHMENTS_ALL_MEMBERS = 4; // groupSignature
// }
//
// // @required
// required Type type = 1;
// repeated bytes members = 2;
// @required
// required bytes groupSignature = 3; // used by every members to make sure incoming admin action can be trusted
// }

// message GroupMemberLeftMessage {
// the pubkey of the member who left is already in the senderIdentity
// }


message DataMessage {
Expand Down Expand Up @@ -225,7 +188,6 @@ message DataMessage {
optional ClosedGroupControlMessage closedGroupControlMessage = 104;
optional string syncTarget = 105;
optional bool blocksCommunityMessageRequests = 106;
// optional GroupMessage groupMessage = 120;
}

message CallMessage {
Expand Down
7 changes: 5 additions & 2 deletions ts/components/SessionInboxView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useMount from 'react-use/lib/useMount';

import { LeftPane } from './leftpane/LeftPane';
// moment does not support es-419 correctly (and cause white screen on app start)
import { getConversationController } from '../session/conversations';
import { ConvoHub } from '../session/conversations';
import { UserUtils } from '../session/utils';
import { createStore } from '../state/createStore';
import { initialCallState } from '../state/ducks/call';
Expand Down Expand Up @@ -39,6 +39,7 @@ import { useHasDeviceOutdatedSyncing } from '../state/selectors/settings';
import { Storage } from '../util/storage';
import { NoticeBanner } from './NoticeBanner';
import { Flex } from './basic/Flex';
import { groupInfoActions, initialGroupState } from '../state/ducks/groups';

function makeLookup<T>(items: Array<T>, key: string): { [key: string]: T } {
// Yep, we can't index into item without knowing what it is. True. But we want to.
Expand All @@ -60,7 +61,7 @@ const StyledGutter = styled.div`

function createSessionInboxStore() {
// Here we set up a full redux store with initial state for our LeftPane Root
const conversations = getConversationController()
const conversations = ConvoHub.use()
yougotwill marked this conversation as resolved.
Show resolved Hide resolved
.getConversations()
.map(conversation => conversation.getConversationModelProps());

Expand Down Expand Up @@ -88,6 +89,7 @@ function createSessionInboxStore() {
call: initialCallState,
sogsRoomInfo: initialSogsRoomInfoState,
settings: getSettingsInitialState(),
groups: initialGroupState,
yougotwill marked this conversation as resolved.
Show resolved Hide resolved
};

return createStore(initialState);
Expand All @@ -97,6 +99,7 @@ function setupLeftPane(forceUpdateInboxComponent: () => void) {
window.openConversationWithMessages = openConversationWithMessages;
window.inboxStore = createSessionInboxStore();
window.inboxStore.dispatch(updateAllOnStorageReady());
window.inboxStore.dispatch(groupInfoActions.loadMetaDumpsFromDB()); // this loads the dumps from DB and fills the 03-groups slice with the corresponding details
forceUpdateInboxComponent();
}

Expand Down
11 changes: 2 additions & 9 deletions ts/components/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,8 @@ const AvatarImage = (
};

const AvatarInner = (props: Props) => {
const {
base64Data,
size,
pubkey,
forcedAvatarPath,
forcedName,
dataTestId,
onAvatarClick,
} = props;
const { base64Data, size, pubkey, forcedAvatarPath, forcedName, dataTestId, onAvatarClick } =
props;
const [imageBroken, setImageBroken] = useState(false);

const isSelectingMessages = useSelector(isMessageSelectionMode);
Expand Down
12 changes: 2 additions & 10 deletions ts/components/basic/SessionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,8 @@ type Props = {
};

export const SessionButton = (props: Props) => {
const {
buttonType,
buttonShape,
dataTestId,
buttonColor,
text,
disabled,
onClick,
margin,
} = props;
const { buttonType, buttonShape, dataTestId, buttonColor, text, disabled, onClick, margin } =
props;

const clickHandler = (e: any) => {
if (onClick) {
Expand Down
4 changes: 3 additions & 1 deletion ts/components/basic/SessionToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const StyledKnob = styled.div<{ active: boolean }>`
? '-2px 1px 3px var(--toggle-switch-ball-shadow-color);'
: '2px 1px 3px var(--toggle-switch-ball-shadow-color);'};

transition: transform var(--default-duration) ease, background-color var(--default-duration) ease;
transition:
transform var(--default-duration) ease,
background-color var(--default-duration) ease;

transform: ${props => (props.active ? 'translateX(25px)' : '')};
`;
Expand Down
4 changes: 2 additions & 2 deletions ts/components/conversation/AddMentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import styled from 'styled-components';
import { RenderTextCallbackType } from '../../types/Util';
import { PubKey } from '../../session/types';
import { getConversationController } from '../../session/conversations';
import { ConvoHub } from '../../session/conversations';
import { isUsAnySogsFromCache } from '../../session/apis/open_group_api/sogsv3/knownBlindedkeys';

interface MentionProps {
Expand All @@ -26,7 +26,7 @@ const StyledMentionedUs = styled(StyledMentionAnother)`

const Mention = (props: MentionProps) => {
const blindedOrNotPubkey = props.text.slice(1);
const foundConvo = getConversationController().get(blindedOrNotPubkey);
const foundConvo = ConvoHub.use().get(blindedOrNotPubkey);

// this call takes care of finding if we have a blindedId of ourself on any sogs we have joined.
if (isUsAnySogsFromCache(blindedOrNotPubkey)) {
Expand Down
12 changes: 7 additions & 5 deletions ts/components/conversation/ContactName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export const ContactName = (props: Props) => {
const convoName = useConversationUsernameOrShorten(pubkey);
const isPrivate = useIsPrivate(pubkey);
const shouldShowProfile = Boolean(convoName || profileName || name);
const styles = (boldProfileName
? {
fontWeight: 'bold',
}
: {}) as React.CSSProperties;
const styles = (
boldProfileName
? {
fontWeight: 'bold',
}
: {}
) as React.CSSProperties;
const textProfile = profileName || name || convoName || window.i18n('anonymous');

return (
Expand Down
24 changes: 11 additions & 13 deletions ts/components/conversation/ConversationHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ import {
useSelectedIsBlocked,
useSelectedIsGroup,
useSelectedIsKickedFromGroup,
useSelectedIsNoteToSelf,
useSelectedIsPrivate,
useSelectedIsPrivateFriend,
useSelectedIsPublic,
useSelectedMembers,
useSelectedMembersCount,
useSelectedNotificationSetting,
useSelectedSubscriberCount,
useSelectedisNoteToSelf,
} from '../../state/selectors/selectedConversation';
import { ExpirationTimerOptions } from '../../util/expiringMessages';
import { Flex } from '../basic/Flex';
Expand All @@ -65,6 +65,7 @@ const SelectionOverlay = () => {
const selectedConversationKey = useSelectedConversationKey();
const isPublic = useSelectedIsPublic();
const dispatch = useDispatch();
const isMe = useSelectedIsNoteToSelf();

const { i18n } = window;

Expand All @@ -85,7 +86,9 @@ const SelectionOverlay = () => {

const isOnlyServerDeletable = isPublic;
const deleteMessageButtonText = i18n('delete');
const deleteForEveryoneMessageButtonText = i18n('deleteForEveryone');
const deleteForEveryoneMessageButtonText = isMe
? i18n('deleteFromAllMyDevices')
: i18n('deleteForEveryone');
yougotwill marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className="message-selection-overlay">
Expand Down Expand Up @@ -213,7 +216,7 @@ const CallButton = () => {
const isPrivate = useSelectedIsPrivate();
const isBlocked = useSelectedIsBlocked();
const isActive = useSelectedIsActive();
const isMe = useSelectedisNoteToSelf();
const isMe = useSelectedIsNoteToSelf();
const selectedConvoKey = useSelectedConversationKey();

const hasIncomingCall = useSelector(getHasIncomingCall);
Expand Down Expand Up @@ -292,9 +295,9 @@ const ConversationHeaderTitle = () => {

const isPublic = useSelectedIsPublic();
const isKickedFromGroup = useSelectedIsKickedFromGroup();
const isMe = useSelectedisNoteToSelf();
const isMe = useSelectedIsNoteToSelf();
const isGroup = useSelectedIsGroup();
const members = useSelectedMembers();
let memberCount = useSelectedMembersCount();

if (!selectedConvoKey) {
return null;
Expand All @@ -306,13 +309,8 @@ const ConversationHeaderTitle = () => {
return <div className="module-conversation-header__title">{i18n('noteToSelf')}</div>;
}

let memberCount = 0;
if (isGroup) {
if (isPublic) {
memberCount = subscriberCount || 0;
} else {
memberCount = members.length;
}
if (isPublic) {
memberCount = subscriberCount || 0;
}

let memberCountText = '';
Expand Down