Simplify references to VerificationRequest (#11045)

* Use new `VerificationRequest.getQRCodeBytes()`

* Use new `VerificationRequest.otherDeviceId`

* Remove references to `VerificationRequest.channel`

* Replace references to `VerificationRequest.{requesting,receiving}UserId`

Normally these are guarded by `request.initiatedByMe` so we can trivially
replace it with `request.otherUserId` or `client.getUserId()`. In one place we
actually need to apply some logic.

* increase test coverage

* Even more test coverage

* Even more test coverage
This commit is contained in:
Richard van der Hoff 2023-06-07 15:43:44 +01:00 committed by GitHub
parent ac2c9cef8d
commit 34439ee652
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 310 additions and 33 deletions

View file

@ -74,11 +74,11 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
if (request.isSelfVerification) {
const cli = MatrixClientPeg.get();
const device = request.channel.deviceId ? await cli.getDevice(request.channel.deviceId) : null;
const device = request.otherDeviceId ? await cli.getDevice(request.otherDeviceId) : null;
const ip = device?.last_seen_ip;
this.setState({
device:
(request.channel.deviceId && cli.getStoredDevice(cli.getSafeUserId(), request.channel.deviceId)) ||
(request.otherDeviceId && cli.getStoredDevice(cli.getSafeUserId(), request.otherDeviceId)) ||
undefined,
ip,
});
@ -113,10 +113,10 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
// no room id for to_device requests
const cli = MatrixClientPeg.get();
try {
if (request.channel.roomId) {
if (request.roomId) {
dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: request.channel.roomId,
room_id: request.roomId,
should_peek: false,
metricsTrigger: "VerificationRequest",
});
@ -128,7 +128,7 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
{ phase: RightPanelPhases.EncryptionPanel, state: { verificationRequest: request, member } },
],
undefined,
request.channel.roomId,
request.roomId,
);
} else {
Modal.createDialog(
@ -164,7 +164,7 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
}
} else {
const userId = request.otherUserId;
const roomId = request.channel.roomId;
const roomId = request.roomId;
description = roomId ? userLabelForEventRoom(MatrixClientPeg.get(), userId, roomId) : userId;
// for legacy to_device verification requests
if (description === userId) {