2020-01-31 14:01:32 +01:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
|
Copyright 2020, 2021 The Matrix.org Foundation C.I.C.
|
2020-01-31 14:01:32 +01:00
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2020-01-31 14:01:32 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type VerificationRequest } from "matrix-js-sdk/src/crypto-api";
|
|
|
|
|
import { type User } from "matrix-js-sdk/src/matrix";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2021-06-29 13:11:58 +01:00
|
|
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
2020-02-01 18:25:01 +01:00
|
|
|
import { _t } from "../../../languageHandler";
|
2021-07-01 14:22:58 +01:00
|
|
|
import BaseDialog from "./BaseDialog";
|
|
|
|
|
import EncryptionPanel from "../right_panel/EncryptionPanel";
|
|
|
|
|
|
|
|
|
|
interface IProps {
|
2023-02-28 10:31:48 +00:00
|
|
|
verificationRequest?: VerificationRequest;
|
|
|
|
|
verificationRequestPromise?: Promise<VerificationRequest>;
|
2021-07-01 14:22:58 +01:00
|
|
|
onFinished: () => void;
|
2023-02-28 10:31:48 +00:00
|
|
|
member?: User;
|
2021-07-01 14:22:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface IState {
|
2023-02-28 10:31:48 +00:00
|
|
|
verificationRequest?: VerificationRequest;
|
2021-07-01 14:22:58 +01:00
|
|
|
}
|
2020-01-31 14:01:32 +01:00
|
|
|
|
2021-07-01 14:22:58 +01:00
|
|
|
export default class VerificationRequestDialog extends React.Component<IProps, IState> {
|
2023-02-13 11:39:16 +00:00
|
|
|
public constructor(props: IProps) {
|
2021-07-01 14:22:58 +01:00
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
verificationRequest: this.props.verificationRequest,
|
|
|
|
|
};
|
2024-11-01 17:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public componentDidMount(): void {
|
2023-02-28 10:31:48 +00:00
|
|
|
this.props.verificationRequestPromise?.then((r) => {
|
|
|
|
|
this.setState({ verificationRequest: r });
|
|
|
|
|
});
|
2020-02-18 11:14:16 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2020-04-02 17:12:10 +02:00
|
|
|
const request = this.state.verificationRequest;
|
2023-02-28 10:31:48 +00:00
|
|
|
const otherUserId = request?.otherUserId;
|
2023-06-15 08:46:19 +01:00
|
|
|
const member = this.props.member || (otherUserId ? MatrixClientPeg.safeGet().getUser(otherUserId) : null);
|
2023-10-03 19:17:26 +01:00
|
|
|
const title = request?.isSelfVerification
|
|
|
|
|
? _t("encryption|verification|verification_dialog_title_device")
|
|
|
|
|
: _t("encryption|verification|verification_dialog_title_user");
|
2020-04-02 17:12:10 +02:00
|
|
|
|
2023-05-25 09:39:23 +01:00
|
|
|
if (!member) return null;
|
|
|
|
|
|
2021-04-27 17:23:27 +02:00
|
|
|
return (
|
|
|
|
|
<BaseDialog
|
|
|
|
|
className="mx_InfoDialog"
|
|
|
|
|
onFinished={this.props.onFinished}
|
|
|
|
|
contentId="mx_Dialog_content"
|
|
|
|
|
title={title}
|
|
|
|
|
hasCancel={true}
|
|
|
|
|
>
|
2020-02-01 18:25:01 +01:00
|
|
|
<EncryptionPanel
|
|
|
|
|
layout="dialog"
|
|
|
|
|
verificationRequest={this.props.verificationRequest}
|
2020-03-10 18:59:45 +01:00
|
|
|
verificationRequestPromise={this.props.verificationRequestPromise}
|
2020-02-01 18:25:01 +01:00
|
|
|
onClose={this.props.onFinished}
|
2020-03-10 18:59:45 +01:00
|
|
|
member={member}
|
2021-07-01 14:22:58 +01:00
|
|
|
isRoomEncrypted={false}
|
2020-02-01 18:25:01 +01:00
|
|
|
/>
|
|
|
|
|
</BaseDialog>
|
|
|
|
|
);
|
2020-01-31 14:01:32 +01:00
|
|
|
}
|
|
|
|
|
}
|