Skip to content

Commit

Permalink
fix: various PR reviews, fixes for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Nov 25, 2024
1 parent d5f9b7a commit d2dd98c
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Remember, you can preview this before saving it.
### Contributor checklist:

- [ ] My commits are in nice logical chunks with [good commit messages](http://chris.beams.io/posts/git-commit/)
- [ ] My changes are [rebased](https://blog.axosoft.com/golden-rule-of-rebasing-in-git/) on the latest [`clearnet`](https://github.com/session-foundation/session-desktop/tree/clearnet) branch
- [ ] My changes are [rebased](https://blog.axosoft.com/golden-rule-of-rebasing-in-git/) on the latest [`unstable`](https://github.com/session-foundation/session-desktop/tree/clearnet) branch
- [ ] A `yarn ready` run passes successfully ([more about tests here](https://github.com/session-foundation/session-desktop/blob/master/CONTRIBUTING.md#tests))
- [ ] My changes are ready to be shipped to users

Expand Down
1 change: 0 additions & 1 deletion protos/SignalService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ message GroupUpdateMessage {
optional GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8;
}


message DataMessage {

// 7 = timestamp unused and should not be used
Expand Down
2 changes: 1 addition & 1 deletion ts/components/MemberListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const StyledGroupStatusText = styled.span<{ isFailure: boolean }>`
font-size: var(--font-size-xs);
margin-top: var(--margins-xs);
min-width: 100px; // min-width so that the dialog does not resize when the status change to sending
text-align: left;
text-align: start;
`;

const GroupStatusText = ({ groupPk, pubkey }: { pubkey: PubkeyType; groupPk: GroupPubkeyType }) => {
Expand Down
6 changes: 5 additions & 1 deletion ts/components/conversation/MessageRequestButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ConversationOutgoingRequestExplanation,
InvitedToGroupControlMessage,
} from './SubtleNotification';
import { NetworkTime } from '../../util/NetworkTime';

const MessageRequestContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -101,7 +102,10 @@ export const ConversationMessageRequestButtons = () => {
<ConversationBannerRow>
<SessionButton
onClick={() => {
void handleAcceptConversationRequest({ convoId: selectedConvoId });
void handleAcceptConversationRequest({
convoId: selectedConvoId,
approvalMessageTimestamp: NetworkTime.now(),
});
}}
text={window.i18n('accept')}
dataTestId="accept-message-request"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,14 @@ export const OverlayRightPanelSettings = () => {

<MediaGallery documents={documents} media={media} />
{isGroup && (
<>
<PanelIconButton
text={leaveGroupString}
dataTestId="leave-group-button"
disabled={isKickedFromGroup}
onClick={() => void deleteConvoAction()}
color={'var(--danger-color)'}
iconType={'delete'}
/>
</>
<PanelIconButton
text={leaveGroupString}
dataTestId="leave-group-button"
disabled={isKickedFromGroup}
onClick={() => void deleteConvoAction()}
color={'var(--danger-color)'}
iconType={'delete'}
/>
)}
</PanelButtonGroup>
<SpacerLG />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const TimeOptions = (props: TimerOptionsProps) => {
setSelected(option.value);
}}
disabled={disabled}
dataTestId={`time-option-${option.value}`} // we want "time-option-3600", etc as accessibility id
dataTestId={`time-option-${option.value}-seconds`} // we want "time-option-3600-seconds", etc as accessibility id
/>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions ts/components/dialog/InviteContactsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/S
import { SessionSpinner } from '../loading';
import { SessionToggle } from '../basic/SessionToggle';
import { GroupInviteRequiredVersionBanner } from '../NoticeBanner';
import { isDevProd } from '../../shared/env_vars';
import { hasClosedGroupV2QAButtons } from '../../shared/env_vars';
import { ConversationTypeEnum } from '../../models/types';
import { Localizer } from '../basic/Localizer';

Expand Down Expand Up @@ -188,7 +188,7 @@ const InviteContactsDialogInner = (props: Props) => {
<SpacerLG />

{/* TODO: localize those strings once out releasing those buttons for real Remove after QA */}
{isGroupV2 && isDevProd() && (
{isGroupV2 && hasClosedGroupV2QAButtons() && (
<>
<span style={{ display: 'flex', alignItems: 'center' }}>
Share History?{' '}
Expand Down
1 change: 0 additions & 1 deletion ts/components/dialog/UpdateGroupNameDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export function UpdateGroupNameDialog(props: { conversationId: string }) {
const cancelText = window.i18n('cancel');

const isAdmin = !isCommunity;
// return null;

return (
<SessionWrapperModal
Expand Down
4 changes: 2 additions & 2 deletions ts/components/leftpane/overlay/OverlayClosedGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { VALIDATION } from '../../../session/constants';
import { createClosedGroup } from '../../../session/conversations/createClosedGroup';
import { ToastUtils } from '../../../session/utils';
import LIBSESSION_CONSTANTS from '../../../session/utils/libsession/libsession_constants';
import { isDevProd } from '../../../shared/env_vars';
import { groupInfoActions } from '../../../state/ducks/metaGroups';
import { clearSearch } from '../../../state/ducks/search';
import { resetLeftOverlayMode } from '../../../state/ducks/section';
Expand All @@ -35,6 +34,7 @@ import { SpacerLG, SpacerMD } from '../../basic/Text';
import { SessionInput } from '../../inputs';
import { SessionSpinner } from '../../loading';
import { StyledLeftPaneOverlay } from './OverlayMessage';
import { hasClosedGroupV2QAButtons } from '../../../shared/env_vars';

const StyledMemberListNoContacts = styled.div`
text-align: center;
Expand Down Expand Up @@ -195,7 +195,7 @@ export const OverlayClosedGroupV2 = () => {
</div>
<SessionSpinner loading={isCreatingGroup} />
{/* TODO: localize those strings once out releasing those buttons for real Remove after QA */}
{isDevProd() && (
{hasClosedGroupV2QAButtons() && (
<>
<span style={{ display: 'flex', alignItems: 'center' }}>
Invite as admin?{' '}
Expand Down
2 changes: 2 additions & 0 deletions ts/components/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
ConversationInteractionType,
} from '../../interactions/types';
import { useLibGroupDestroyed } from '../../state/selectors/userGroups';
import { NetworkTime } from '../../util/NetworkTime';

/** Menu items standardized */

Expand Down Expand Up @@ -446,6 +447,7 @@ export const AcceptMsgRequestMenuItem = () => {
onClick={async () => {
await handleAcceptConversationRequest({
convoId,
approvalMessageTimestamp: NetworkTime.now(),
});
}}
dataTestId="accept-menu-item"
Expand Down
2 changes: 1 addition & 1 deletion ts/hooks/useParamSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function useIsOutgoingRequest(convoId?: string) {

/**
* Note: NOT to be exported:
* This selector is too generic and needs to be broken node in individual fields selectors.
* This selector is too generic and needs to be broken down into individual fields selectors.
* Make sure when writing a selector that you fetch the data from libsession if needed.
* (check useSortedGroupMembers() as an example)
*/
Expand Down
19 changes: 16 additions & 3 deletions ts/interactions/conversationInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,20 @@ export async function unblockConvoById(conversationId: string) {
);
}

export const handleAcceptConversationRequest = async ({ convoId }: { convoId: string }) => {
/**
* Accept if needed the message request from this user.
* Note: approvalMessageTimestamp is provided to be able to insert the "You've accepted the message request" at the right place.
* When accepting a message request by sending a message, we need to make sure the "You've accepted the message request" is before the
* message we are sending to the user.
*
*/
export const handleAcceptConversationRequest = async ({
convoId,
approvalMessageTimestamp,
}: {
convoId: string;
approvalMessageTimestamp: number;
}) => {
const convo = ConvoHub.use().get(convoId);
if (!convo || (!convo.isPrivate() && !convo.isClosedGroupV2())) {
return null;
Expand All @@ -111,7 +124,7 @@ export const handleAcceptConversationRequest = async ({ convoId }: { convoId: st
if (convo.isPrivate()) {
// we only need the approval message (and sending a reply) when we are accepting a message request. i.e. someone sent us a message already and we didn't accept it yet.
if (!previousIsApproved && previousDidApprovedMe) {
await convo.addOutgoingApprovalMessage(Date.now());
await convo.addOutgoingApprovalMessage(approvalMessageTimestamp);
await convo.sendMessageRequestResponse();
}

Expand Down Expand Up @@ -993,7 +1006,7 @@ export async function promoteUsersInGroup({
return;
}

// push one group change message were initial members are added to the group
// push one group change message where initial members are added to the group
const membersHex = uniq(toPromote);
const sentAt = NetworkTime.now();
const us = UserUtils.getOurPubKeyStrFromCache();
Expand Down
2 changes: 2 additions & 0 deletions ts/models/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
// handleAcceptConversationRequest will take care of sending response depending on the type of conversation, if needed
await handleAcceptConversationRequest({
convoId: this.id,
approvalMessageTimestamp: NetworkTime.now() - 100,
});

if (this.isOpenGroupV2()) {
Expand Down Expand Up @@ -2109,6 +2110,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
// handleAcceptConversationRequest will take care of sending response depending on the type of conversation
await handleAcceptConversationRequest({
convoId: this.id,
approvalMessageTimestamp: NetworkTime.now() - 100,
});

if (this.isOpenGroupV2()) {
Expand Down
4 changes: 2 additions & 2 deletions ts/node/hexStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const isHexString = (maybeHex: string) =>
/**
* Returns the Uint8Array corresponding to the given string.
* Note: this is different than the libsodium.from_hex().
* This takes a string like "0102" and converts it to an UIin8Array like [1, 2] whereare
* This takes a string like "0102" and converts it to an UInt8Array like [1, 2] where
* the libsodium one returns [0, 1, 0, 2]
*
* Throws an error if this string is not a hex string.
* @param hexString the string to convert from
* @returns the Uint8Arrat
* @returns the Uint8Array
*/
const fromHexString = (hexString: string): Uint8Array => {
if (!isHexString(hexString)) {
Expand Down
26 changes: 13 additions & 13 deletions ts/react.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ declare module 'react' {
| 'accept-menu-item'

// timer options
| 'time-option-0'
| 'time-option-5'
| 'time-option-10'
| 'time-option-30'
| 'time-option-60'
| 'time-option-300'
| 'time-option-1800'
| 'time-option-3600'
| 'time-option-21600'
| 'time-option-43200'
| 'time-option-86400'
| 'time-option-604800'
| 'time-option-1209600'
| 'time-option-0-seconds'
| 'time-option-5-seconds'
| 'time-option-10-seconds'
| 'time-option-30-seconds'
| 'time-option-60-seconds'
| 'time-option-300-seconds'
| 'time-option-1800-seconds'
| 'time-option-3600-seconds'
| 'time-option-21600-seconds'
| 'time-option-43200-seconds'
| 'time-option-86400-seconds'
| 'time-option-604800-seconds'
| 'time-option-1209600-seconds'

// generic readably message (not control message)
| 'message-content'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ async function handleMetaMergeResults(groupPk: GroupPubkeyType) {
);
}
}
// mark ourselves as accepting the invite if needed
if (usMember?.memberStatus === 'INVITE_SENT' && keysAlreadyHaveAdmin) {
await MetaGroupWrapperActions.memberSetAccepted(groupPk, us);
}
// mark ourselves as accepting the promotion if needed
if (usMember?.memberStatus === 'PROMOTION_SENT' && keysAlreadyHaveAdmin) {
// Note: this call won't change anything if we are already an "accepted" admin, but will
// overwrite any other states for promotion.
if (keysAlreadyHaveAdmin && usMember) {
// mark ourselves as accepting the promotion if needed.
await MetaGroupWrapperActions.memberSetPromotionAccepted(groupPk, us);
}
// this won't do anything if there is no need for a sync, so we can safely plan one
Expand Down
1 change: 1 addition & 0 deletions ts/session/onions/onionPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ async function buildNewOnionPathsWorker() {
}

window?.log?.info(`Built ${onionPaths.length} onion paths`);
window?.log?.debug(`onionPaths:`, JSON.stringify(onionPaths));
},
{
retries: 3, // 4 total
Expand Down
6 changes: 5 additions & 1 deletion ts/session/utils/calling/CallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,10 @@ export async function USER_callRecipient(recipient: string) {
weAreCallerOnCurrentCall = true;

// initiating a call is analogous to sending a message request
await handleAcceptConversationRequest({ convoId: recipient });
await handleAcceptConversationRequest({
convoId: recipient,
approvalMessageTimestamp: NetworkTime.now() - 100,
});

// Note: we do the sending of the preoffer manually as the sendTo1o1NonDurably rely on having a message saved to the db for MessageSentSuccess
// which is not the case for a pre offer message (the message only exists in memory)
Expand Down Expand Up @@ -936,6 +939,7 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
// consider the conversation completely approved
await handleAcceptConversationRequest({
convoId: fromSender,
approvalMessageTimestamp: NetworkTime.now() - 100,
});
}

Expand Down
8 changes: 4 additions & 4 deletions ts/session/utils/libsession/libsession_utils_multi_encrypt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EncryptionDomain } from 'libsession_util_nodejs';
import { MultiEncryptWrapperActions } from '../../../webworker/workers/browser/libsession_worker_interface';

const allKnownEncryptionDomains: Array<EncryptionDomain> = ['SessionGroupKickedMessage'];
import {
allKnownEncryptionDomains,
MultiEncryptWrapperActions,
} from '../../../webworker/workers/browser/libsession_worker_interface';

/**
* Try to decrypt the content with any type of encryption domains we know.
Expand Down
2 changes: 1 addition & 1 deletion ts/state/ducks/metaGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const initNewGroupInWrapper = createAsyncThunk(
await convo.setIsApproved(true, false);
await convo.commit(); // commit here too, as the poll needs it to be approved
let groupMemberChange: GroupUpdateMemberChangeMessage | null = null;
// push one group change message were initial members are added to the group
// push one group change message where initial members are added to the group
if (membersFromWrapper.length) {
const membersHex = uniq(membersFromWrapper.map(m => m.pubkeyHex));
const sentAt = NetworkTime.now();
Expand Down
3 changes: 2 additions & 1 deletion ts/webworker/workers/browser/libsession_worker_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
UserGroupsGet,
UserGroupsSet,
UserGroupsWrapperActionsCalls,
EncryptionDomain,
} from 'libsession_util_nodejs';
// eslint-disable-next-line import/order
import { join } from 'path';
Expand Down Expand Up @@ -758,7 +759,7 @@ export const MultiEncryptWrapperActions: MultiEncryptActionsCalls = {
>,
};

export const EncryptionDomains = ['SessionGroupKickedMessage'] as const;
export const allKnownEncryptionDomains: Array<EncryptionDomain> = ['SessionGroupKickedMessage'];

export const BlindingActions: BlindingActionsCalls = {
blindVersionPubkey: async (opts: Parameters<BlindingActionsCalls['blindVersionPubkey']>[0]) =>
Expand Down

0 comments on commit d2dd98c

Please sign in to comment.