report IP of self-verification reqs

pull/21833/head
Matthew Hodgson 2021-03-08 04:46:47 +00:00
parent 5b48e13eb9
commit aa0cca9306
1 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,7 @@ interface IProps {
interface IState { interface IState {
counter: number; counter: number;
device?: DeviceInfo; device?: DeviceInfo;
IP?: string;
} }
export default class VerificationRequestToast extends React.PureComponent<IProps, IState> { export default class VerificationRequestToast extends React.PureComponent<IProps, IState> {
@ -66,9 +67,15 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
// a toast hanging around after logging in if you did a verification as part of login). // a toast hanging around after logging in if you did a verification as part of login).
this._checkRequestIsPending(); this._checkRequestIsPending();
if (request.isSelfVerification) { if (request.isSelfVerification) {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
this.setState({device: cli.getStoredDevice(cli.getUserId(), request.channel.deviceId)}); const device = await cli.getDevice(request.channel.deviceId);
const IP = device.last_seen_ip;
this.setState({
device: cli.getStoredDevice(cli.getUserId(), request.channel.deviceId),
IP,
});
} }
} }
@ -118,6 +125,9 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog"); const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog");
Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, {
verificationRequest: request, verificationRequest: request,
onFinished: () => {
request.cancel();
},
}, null, /* priority = */ false, /* static = */ true); }, null, /* priority = */ false, /* static = */ true);
} }
await request.accept(); await request.accept();
@ -131,9 +141,10 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
let nameLabel; let nameLabel;
if (request.isSelfVerification) { if (request.isSelfVerification) {
if (this.state.device) { if (this.state.device) {
nameLabel = _t("From %(deviceName)s (%(deviceId)s)", { nameLabel = _t("From %(deviceName)s (%(deviceId)s) from %(IP)s", {
deviceName: this.state.device.getDisplayName(), deviceName: this.state.device.getDisplayName(),
deviceId: this.state.device.deviceId, deviceId: this.state.device.deviceId,
IP: this.state.IP,
}); });
} }
} else { } else {