Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into dbkr/refactor_crea…
Browse files Browse the repository at this point in the history
…tecrosssigningdialog
  • Loading branch information
dbkr committed Oct 18, 2024
2 parents 532d678 + 59cd518 commit 65fffd8
Show file tree
Hide file tree
Showing 48 changed files with 468 additions and 534 deletions.
5 changes: 4 additions & 1 deletion playwright/e2e/chat-export/html-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ test.describe("HTML Export", () => {

// Send a bunch of messages to populate the room
for (let i = 1; i < 10; i++) {
await app.client.sendMessage(room.roomId, { body: `Testing ${i}`, msgtype: "m.text" });
const respone = await app.client.sendMessage(room.roomId, { body: `Testing ${i}`, msgtype: "m.text" });
if (i == 1) {
await app.client.reactToMessage(room.roomId, null, respone.event_id, "🙃");
}
}

// Wait for all the messages to be displayed
Expand Down
9 changes: 1 addition & 8 deletions playwright/e2e/read-receipts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,7 @@ export class MessageBuilder {
threadId: !ev.isThreadRoot ? ev.threadRootId : undefined,
}));
const roomId = await room.evaluate((room) => room.roomId);

await bot.sendEvent(roomId, threadId ?? null, "m.reaction", {
"m.relates_to": {
rel_type: "m.annotation",
event_id: id,
key: reaction,
},
});
await bot.reactToMessage(roomId, threadId, id, reaction);
}
})(this);
}
Expand Down
23 changes: 23 additions & 0 deletions playwright/pages/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ export class Client {
);
}

/**
* Send a reaction to to a message
* @param roomId ID of the room to send the reaction into
* @param threadId ID of the thread to send into or null for main timeline
* @param eventId Event ID of the message you are reacting to
* @param reaction The reaction text to send
* @returns
*/
public async reactToMessage(
roomId: string,
threadId: string | null,
eventId: string,
reaction: string,
): Promise<ISendEventResponse> {
return this.sendEvent(roomId, threadId ?? null, "m.reaction", {
"m.relates_to": {
rel_type: "m.annotation",
event_id: eventId,
key: reaction,
},
});
}

/**
* Create a room with given options.
* @param options the options to apply when creating the room
Expand Down
2 changes: 1 addition & 1 deletion playwright/plugins/homeserver/synapse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { randB64Bytes } from "../../utils/rand";
// Docker tag to use for synapse docker image.
// We target a specific digest as every now and then a Synapse update will break our CI.
// This digest is updated by the playwright-image-updates.yaml workflow periodically.
const DOCKER_TAG = "develop@sha256:fd6ba2d8471a0807e1bccef4124b22d17f0058f2cf9285066fdd94d8c631964a";
const DOCKER_TAG = "develop@sha256:47c62aa9507a24820190eef547861c0d278cc83fe90329c46b9f4329eed88ef4";

async function cfgDirFromTemplate(opts: StartHomeserverOpts): Promise<Omit<HomeserverConfig, "dockerUrl">> {
const templateDir = path.join(__dirname, "templates", opts.template);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/SlashCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ export const Commands = [
isEnabled: (cli) => !isCurrentLocalRoom(cli),
runFn: function (cli, roomId) {
try {
cli.forceDiscardSession(roomId);
cli.getCrypto()?.forceDiscardSession(roomId);
} catch (e) {
return reject(e instanceof Error ? e.message : e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,92 +7,82 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/

import React from "react";
import { KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
import React, { JSX, useEffect, useState } from "react";

import { MatrixClientPeg } from "../../../../MatrixClientPeg";
import dis from "../../../../dispatcher/dispatcher";
import { _t } from "../../../../languageHandler";
import Modal from "../../../../Modal";
import RestoreKeyBackupDialog from "../../../../components/views/dialogs/security/RestoreKeyBackupDialog";
import { Action } from "../../../../dispatcher/actions";
import DialogButtons from "../../../../components/views/elements/DialogButtons";
import BaseDialog from "../../../../components/views/dialogs/BaseDialog";
import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext.tsx";

interface IProps {
newVersionInfo: KeyBackupInfo;
/**
* Properties for {@link NewRecoveryMethodDialog}.
*/
interface NewRecoveryMethodDialogProps {
/**
* Callback when the dialog is dismissed.
*/
onFinished(): void;
}

export default class NewRecoveryMethodDialog extends React.PureComponent<IProps> {
private onOkClick = (): void => {
this.props.onFinished();
};
// Export as default instead of a named export so that it can be dynamically imported with `Modal.createDialogAsync`

private onGoToSettingsClick = (): void => {
this.props.onFinished();
dis.fire(Action.ViewUserSettings);
};
/**
* Dialog to inform the user that a new recovery method has been detected.
*/
export default function NewRecoveryMethodDialog({ onFinished }: NewRecoveryMethodDialogProps): JSX.Element {
const matrixClient = useMatrixClientContext();
const [isKeyBackupEnabled, setIsKeyBackupEnabled] = useState(false);
useEffect(() => {
const checkBackupEnabled = async (): Promise<void> => {
const crypto = matrixClient.getCrypto();
setIsKeyBackupEnabled(Boolean(crypto && (await crypto.getActiveSessionBackupVersion()) !== null));
};

private onSetupClick = async (): Promise<void> => {
Modal.createDialog(
RestoreKeyBackupDialog,
{
onFinished: this.props.onFinished,
},
undefined,
/* priority = */ false,
/* static = */ true,
);
};
checkBackupEnabled();
}, [matrixClient]);

public render(): React.ReactNode {
const title = (
<span className="mx_KeyBackupFailedDialog_title">
{_t("encryption|new_recovery_method_detected|title")}
</span>
);

const newMethodDetected = <p>{_t("encryption|new_recovery_method_detected|description_1")}</p>;

const hackWarning = (
<strong className="warning">{_t("encryption|new_recovery_method_detected|warning")}</strong>
);

let content: JSX.Element | undefined;
if (MatrixClientPeg.safeGet().getKeyBackupEnabled()) {
content = (
<div>
{newMethodDetected}
<p>{_t("encryption|new_recovery_method_detected|description_2")}</p>
{hackWarning}
<DialogButtons
primaryButton={_t("action|ok")}
onPrimaryButtonClick={this.onOkClick}
cancelButton={_t("common|go_to_settings")}
onCancel={this.onGoToSettingsClick}
/>
</div>
);
function onClick(): void {
if (isKeyBackupEnabled) {
onFinished();
} else {
content = (
<div>
{newMethodDetected}
{hackWarning}
<DialogButtons
primaryButton={_t("common|setup_secure_messages")}
onPrimaryButtonClick={this.onSetupClick}
cancelButton={_t("common|go_to_settings")}
onCancel={this.onGoToSettingsClick}
/>
</div>
Modal.createDialog(
RestoreKeyBackupDialog,
{
onFinished,
},
undefined,
false,
true,
);
}

return (
<BaseDialog className="mx_KeyBackupFailedDialog" onFinished={this.props.onFinished} title={title}>
{content}
</BaseDialog>
);
}

return (
<BaseDialog
className="mx_KeyBackupFailedDialog"
onFinished={onFinished}
title={
<span className="mx_KeyBackupFailedDialog_title">
{_t("encryption|new_recovery_method_detected|title")}
</span>
}
>
<p>{_t("encryption|new_recovery_method_detected|description_1")}</p>
{isKeyBackupEnabled && <p>{_t("encryption|new_recovery_method_detected|description_2")}</p>}
<strong className="warning">{_t("encryption|new_recovery_method_detected|warning")}</strong>
<DialogButtons
primaryButton={_t("common|setup_secure_messages")}
onPrimaryButtonClick={onClick}
cancelButton={_t("common|go_to_settings")}
onCancel={() => {
onFinished();
dis.fire(Action.ViewUserSettings);
}}
/>
</BaseDialog>
);
}
7 changes: 5 additions & 2 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1631,8 +1631,12 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
cli.on(CryptoEvent.KeyBackupFailed, async (errcode): Promise<void> => {
let haveNewVersion: boolean | undefined;
let newVersionInfo: KeyBackupInfo | null = null;
const keyBackupEnabled = Boolean(
cli.getCrypto() && (await cli.getCrypto()?.getActiveSessionBackupVersion()) !== null,
);

// if key backup is still enabled, there must be a new backup in place
if (cli.getKeyBackupEnabled()) {
if (keyBackupEnabled) {
haveNewVersion = true;
} else {
// otherwise check the server to see if there's a new one
Expand All @@ -1650,7 +1654,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
import(
"../../async-components/views/dialogs/security/NewRecoveryMethodDialog"
) as unknown as Promise<typeof NewRecoveryMethodDialog>,
{ newVersionInfo: newVersionInfo! },
);
} else {
Modal.createDialogAsync(
Expand Down
39 changes: 29 additions & 10 deletions src/components/views/dialogs/ChangelogDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import Spinner from "../elements/Spinner";
import Heading from "../typography/Heading";

interface IProps {
newVersion: string;
version: string;
newVersion: DevelopVersionString;
version: DevelopVersionString;
onFinished: (success: boolean) => void;
}

Expand All @@ -32,6 +32,28 @@ interface Commit {

const REPOS = ["element-hq/element-web", "matrix-org/matrix-js-sdk"] as const;

export type DevelopVersionString = string & { _developVersionString: never };

/*
* Parse a version string is compatible with the Changelog dialog ([element-version]-js-[js-sdk-version])
*/
export function parseVersion(version: string): Record<(typeof REPOS)[number], string> | null {
const parts = version.split("-");
if (parts.length === 3 && parts[1] === "js") {
const obj: Record<string, string> = {};
for (let i = 0; i < REPOS.length; i++) {
const commit = parts[2 * i];
obj[REPOS[i]] = commit;
}
return obj;
}
return null;
}

export function checkVersion(version: string): version is DevelopVersionString {
return parseVersion(version) !== null;
}

export default class ChangelogDialog extends React.Component<IProps, State> {
public constructor(props: IProps) {
super(props);
Expand All @@ -58,14 +80,11 @@ export default class ChangelogDialog extends React.Component<IProps, State> {
}

public componentDidMount(): void {
const version = this.props.newVersion.split("-");
const version2 = this.props.version.split("-");
if (version == null || version2 == null) return;
// parse versions of form: [vectorversion]-react-[react-sdk-version]-js-[js-sdk-version]
for (let i = 0; i < REPOS.length; i++) {
const oldVersion = version2[2 * i];
const newVersion = version[2 * i];
this.fetchChanges(REPOS[i], oldVersion, newVersion);
const commits = parseVersion(this.props.version)!;
const newCommits = parseVersion(this.props.newVersion)!;

for (const repo of REPOS) {
this.fetchChanges(repo, commits[repo], newCommits[repo]);
}
}

Expand Down
17 changes: 0 additions & 17 deletions src/i18n/strings/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@
"unmute": "Povolit",
"unnamed_room": "Nepojmenovaná místnost",
"unnamed_space": "Nejmenovaný prostor",
"unsent": "Neodeslané",
"unverified": "Neověřeno",
"user": "Uživatel",
"user_avatar": "Profilový obrázek",
Expand Down Expand Up @@ -726,19 +725,11 @@
"low_bandwidth_mode": "Režim malé šířky pásma",
"low_bandwidth_mode_description": "Vyžaduje kompatibilní domovský server.",
"main_timeline": "Hlavní časová osa",
"methods": "Metody",
"no_receipt_found": "Žádné potvrzení o přečtení",
"no_verification_requests_found": "Nebyly nalezeny žádné požadavky na ověření",
"notification_state": "Stav oznámení je <strong>%(notificationState)s</strong>",
"notifications_debug": "Ladění oznámení",
"number_of_users": "Počet uživatelů",
"original_event_source": "Původní zdroj události",
"phase": "Fáze",
"phase_cancelled": "Zrušeno",
"phase_ready": "Připraveno",
"phase_requested": "Požadované",
"phase_started": "Zahájeno",
"phase_transaction": "Transakce",
"room_encrypted": "Místnost je <strong>šifrovaná ✅</strong>",
"room_id": "ID místnosti: %(roomId)s",
"room_not_encrypted": "Místnost <strong>není šifrovaná 🚨</strong>",
Expand Down Expand Up @@ -777,7 +768,6 @@
"state_key": "Stavový klíč",
"thread_root_id": "ID kořenového vlákna: %(threadRootId)s",
"threads_timeline": "Časová osa vláken",
"timeout": "Časový limit",
"title": "Nástroje pro vývojáře",
"toggle_event": "přepnout událost",
"toolbox": "Sada nástrojů",
Expand All @@ -794,7 +784,6 @@
"values_explicit_colon": "Hodnoty na explicitních úrovních:",
"values_explicit_room": "Hodnoty na explicitních úrovních v této místnosti",
"values_explicit_this_room_colon": "Hodnoty na explicitních úrovních v této místnosti:",
"verification_explorer": "Průzkumník ověřování",
"view_servers_in_room": "Zobrazit servery v místnosti",
"view_source_decrypted_event_source": "Dešifrovaný zdroj události",
"view_source_decrypted_event_source_unavailable": "Dešifrovaný zdroj není dostupný",
Expand Down Expand Up @@ -868,10 +857,6 @@
"export_unsupported": "Váš prohlížeč nepodporuje požadovaná kryptografická rozšíření",
"import_invalid_keyfile": "Neplatný soubor s klíčem %(brand)s",
"import_invalid_passphrase": "Kontrola ověření selhala: špatné heslo?",
"incompatible_database_description": "V této relaci jste již dříve používali novější verzi %(brand)s. Chcete-li tuto verzi znovu použít s šifrováním, budete se muset odhlásit a znovu přihlásit.",
"incompatible_database_disable": "Pokračovat bez šifrování",
"incompatible_database_sign_out_description": "Abyste po odhlášení nepřišli o přístup k historii šifrovaných konverzací, měli byste si před odhlášením exportovat šifrovací klíče místností. Prosím vraťte se k novější verzi %(brand)su a exportujte si klíče",
"incompatible_database_title": "Nekompatibilní databáze",
"messages_not_secure": {
"cause_1": "Váš domovský server",
"cause_2": "Domovský server, ke kterému je ověřovaný uživatel připojen",
Expand Down Expand Up @@ -2435,7 +2420,6 @@
"msisdn_verification_field_label": "Ověřovací kód",
"msisdn_verification_instructions": "Zadejte prosím ověřovací SMS kód.",
"msisdns_heading": "Telefonní čísla",
"name_placeholder": "Žádné zobrazované jméno",
"oidc_manage_button": "Spravovat účet",
"password_change_section": "Nastavení nového hesla k účtu…",
"password_change_success": "Vaše heslo bylo úspěšně změněno.",
Expand Down Expand Up @@ -2880,7 +2864,6 @@
"rageshake": "Zaslat hlášení o chybě",
"rainbow": "Pošle zprávu v barvách duhy",
"rainbowme": "Pošle reakci v barvách duhy",
"remakeolm": "Příkaz pro vývojáře: Zruší aktuální odchozí relaci skupiny a nastaví nové relace Olm",
"remove": "Odstraní uživatele s daným id z této místnosti",
"roomavatar": "Změní avatar této místnosti",
"roomname": "Nastaví název místnosti",
Expand Down
Loading

0 comments on commit 65fffd8

Please sign in to comment.