1//! Types for the [`m.key.verification.request`] event.
2//!
3//! [`m.key.verification.request`]: https://spec.matrix.org/latest/client-server-api/#mkeyverificationrequest
45use ruma_common::{MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedTransactionId};
6use ruma_macros::EventContent;
7use serde::{Deserialize, Serialize};
89use super::VerificationMethod;
1011/// The content of an `m.key.verification.request` event.
12#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
13#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
14#[ruma_event(type = "m.key.verification.request", kind = ToDevice)]
15pub struct ToDeviceKeyVerificationRequestEventContent {
16/// The device ID which is initiating the request.
17pub from_device: OwnedDeviceId,
1819/// An opaque identifier for the verification request.
20 ///
21 /// Must be unique with respect to the devices involved.
22pub transaction_id: OwnedTransactionId,
2324/// The verification methods supported by the sender.
25pub methods: Vec<VerificationMethod>,
2627/// The time in milliseconds for when the request was made.
28 ///
29 /// If the request is in the future by more than 5 minutes or more than 10 minutes in
30 /// the past, the message should be ignored by the receiver.
31pub timestamp: MilliSecondsSinceUnixEpoch,
32}
3334impl ToDeviceKeyVerificationRequestEventContent {
35/// Creates a new `ToDeviceKeyVerificationRequestEventContent` with the given device ID,
36 /// transaction ID, methods and timestamp.
37pub fn new(
38 from_device: OwnedDeviceId,
39 transaction_id: OwnedTransactionId,
40 methods: Vec<VerificationMethod>,
41 timestamp: MilliSecondsSinceUnixEpoch,
42 ) -> Self {
43Self { from_device, transaction_id, methods, timestamp }
44 }
45}