fix: various PR reviews, fixes for integration tests

pull/3281/head
Audric Ackermann 6 months ago
parent d5f9b7a6f7
commit d2dd98cd9d
No known key found for this signature in database

@ -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

@ -148,7 +148,6 @@ message GroupUpdateMessage {
optional GroupUpdateMemberLeftNotificationMessage memberLeftNotificationMessage = 8;
}
message DataMessage {
// 7 = timestamp unused and should not be used

@ -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 }) => {

@ -17,6 +17,7 @@ import {
ConversationOutgoingRequestExplanation,
InvitedToGroupControlMessage,
} from './SubtleNotification';
import { NetworkTime } from '../../util/NetworkTime';
const MessageRequestContainer = styled.div`
display: flex;
@ -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"

@ -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 />

@ -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
/>
);
})}

@ -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';
@ -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?{' '}

@ -153,7 +153,6 @@ export function UpdateGroupNameDialog(props: { conversationId: string }) {
const cancelText = window.i18n('cancel');
const isAdmin = !isCommunity;
// return null;
return (
<SessionWrapperModal

@ -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';
@ -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;
@ -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?{' '}

@ -63,6 +63,7 @@ import {
ConversationInteractionType,
} from '../../interactions/types';
import { useLibGroupDestroyed } from '../../state/selectors/userGroups';
import { NetworkTime } from '../../util/NetworkTime';
/** Menu items standardized */
@ -446,6 +447,7 @@ export const AcceptMsgRequestMenuItem = () => {
onClick={async () => {
await handleAcceptConversationRequest({
convoId,
approvalMessageTimestamp: NetworkTime.now(),
});
}}
dataTestId="accept-menu-item"

@ -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)
*/

@ -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;
@ -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();
}
@ -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();

@ -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()) {
@ -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()) {

@ -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)) {

26
ts/react.d.ts vendored

@ -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'

@ -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

@ -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

@ -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)
@ -936,6 +939,7 @@ export async function USER_acceptIncomingCallRequest(fromSender: string) {
// consider the conversation completely approved
await handleAcceptConversationRequest({
convoId: fromSender,
approvalMessageTimestamp: NetworkTime.now() - 100,
});
}

@ -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.

@ -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();

@ -21,6 +21,7 @@ import {
UserGroupsGet,
UserGroupsSet,
UserGroupsWrapperActionsCalls,
EncryptionDomain,
} from 'libsession_util_nodejs';
// eslint-disable-next-line import/order
import { join } from 'path';
@ -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]) =>

Loading…
Cancel
Save