events: Use DeviceId instead of String.
This commit is contained in:
parent
1298c1d690
commit
92110cabb5
@ -11,7 +11,7 @@ mod member_state_key;
|
|||||||
pub use focus::*;
|
pub use focus::*;
|
||||||
pub use member_data::*;
|
pub use member_data::*;
|
||||||
pub use member_state_key::*;
|
pub use member_state_key::*;
|
||||||
use ruma_common::MilliSecondsSinceUnixEpoch;
|
use ruma_common::{MilliSecondsSinceUnixEpoch, OwnedDeviceId};
|
||||||
use ruma_macros::{EventContent, StringEnum};
|
use ruma_macros::{EventContent, StringEnum};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ impl CallMemberEventContent {
|
|||||||
/// Creates a new [`CallMemberEventContent`] with [`SessionMembershipData`].
|
/// Creates a new [`CallMemberEventContent`] with [`SessionMembershipData`].
|
||||||
pub fn new(
|
pub fn new(
|
||||||
application: Application,
|
application: Application,
|
||||||
device_id: String,
|
device_id: OwnedDeviceId,
|
||||||
focus_active: ActiveFocus,
|
focus_active: ActiveFocus,
|
||||||
foci_preferred: Vec<Focus>,
|
foci_preferred: Vec<Focus>,
|
||||||
created_ts: Option<MilliSecondsSinceUnixEpoch>,
|
created_ts: Option<MilliSecondsSinceUnixEpoch>,
|
||||||
@ -234,8 +234,8 @@ mod tests {
|
|||||||
|
|
||||||
use assert_matches2::assert_matches;
|
use assert_matches2::assert_matches;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
device_id, user_id, MilliSecondsSinceUnixEpoch as TS, OwnedEventId, OwnedRoomId,
|
device_id, owned_device_id, user_id, MilliSecondsSinceUnixEpoch as TS, OwnedEventId,
|
||||||
OwnedUserId,
|
OwnedRoomId, OwnedUserId,
|
||||||
};
|
};
|
||||||
use serde_json::{from_value as from_json_value, json, Value as JsonValue};
|
use serde_json::{from_value as from_json_value, json, Value as JsonValue};
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ mod tests {
|
|||||||
call_id: "123456".to_owned(),
|
call_id: "123456".to_owned(),
|
||||||
scope: CallScope::Room,
|
scope: CallScope::Room,
|
||||||
}),
|
}),
|
||||||
device_id: "ABCDE".to_owned(),
|
device_id: owned_device_id!("ABCDE"),
|
||||||
expires: Duration::from_secs(3600),
|
expires: Duration::from_secs(3600),
|
||||||
foci_active: vec![Focus::Livekit(LivekitFocus {
|
foci_active: vec![Focus::Livekit(LivekitFocus {
|
||||||
alias: "1".to_owned(),
|
alias: "1".to_owned(),
|
||||||
@ -274,7 +274,7 @@ mod tests {
|
|||||||
call_id: "123456".to_owned(),
|
call_id: "123456".to_owned(),
|
||||||
scope: CallScope::Room,
|
scope: CallScope::Room,
|
||||||
}),
|
}),
|
||||||
"ABCDE".to_owned(),
|
owned_device_id!("ABCDE"),
|
||||||
ActiveFocus::Livekit(ActiveLivekitFocus {
|
ActiveFocus::Livekit(ActiveLivekitFocus {
|
||||||
focus_selection: FocusSelection::OldestMembership,
|
focus_selection: FocusSelection::OldestMembership,
|
||||||
}),
|
}),
|
||||||
@ -354,7 +354,7 @@ mod tests {
|
|||||||
call_id: "123456".to_owned(),
|
call_id: "123456".to_owned(),
|
||||||
scope: CallScope::Room,
|
scope: CallScope::Room,
|
||||||
}),
|
}),
|
||||||
"THIS_DEVICE".to_owned(),
|
owned_device_id!("THIS_DEVICE"),
|
||||||
ActiveFocus::Livekit(ActiveLivekitFocus {
|
ActiveFocus::Livekit(ActiveLivekitFocus {
|
||||||
focus_selection: FocusSelection::OldestMembership,
|
focus_selection: FocusSelection::OldestMembership,
|
||||||
}),
|
}),
|
||||||
@ -404,7 +404,7 @@ mod tests {
|
|||||||
call_id: "123456".to_owned(),
|
call_id: "123456".to_owned(),
|
||||||
scope: CallScope::Room,
|
scope: CallScope::Room,
|
||||||
}),
|
}),
|
||||||
device_id: "THIS_DEVICE".to_owned(),
|
device_id: owned_device_id!("THIS_DEVICE"),
|
||||||
expires: Duration::from_secs(3600),
|
expires: Duration::from_secs(3600),
|
||||||
foci_active: vec![Focus::Livekit(LivekitFocus {
|
foci_active: vec![Focus::Livekit(LivekitFocus {
|
||||||
alias: "room1".to_owned(),
|
alias: "room1".to_owned(),
|
||||||
@ -418,7 +418,7 @@ mod tests {
|
|||||||
call_id: "".to_owned(),
|
call_id: "".to_owned(),
|
||||||
scope: CallScope::Room,
|
scope: CallScope::Room,
|
||||||
}),
|
}),
|
||||||
device_id: "OTHER_DEVICE".to_owned(),
|
device_id: owned_device_id!("OTHER_DEVICE"),
|
||||||
expires: Duration::from_secs(3600),
|
expires: Duration::from_secs(3600),
|
||||||
foci_active: vec![Focus::Livekit(LivekitFocus {
|
foci_active: vec![Focus::Livekit(LivekitFocus {
|
||||||
alias: "room2".to_owned(),
|
alias: "room2".to_owned(),
|
||||||
@ -526,7 +526,7 @@ mod tests {
|
|||||||
call_id: "".to_owned(),
|
call_id: "".to_owned(),
|
||||||
scope: CallScope::Room,
|
scope: CallScope::Room,
|
||||||
}),
|
}),
|
||||||
device_id: "THIS_DEVICE".to_owned(),
|
device_id: owned_device_id!("THIS_DEVICE"),
|
||||||
foci_preferred: [Focus::Livekit(LivekitFocus {
|
foci_preferred: [Focus::Livekit(LivekitFocus {
|
||||||
alias: "room1".to_owned(),
|
alias: "room1".to_owned(),
|
||||||
service_url: "https://livekit1.com".to_owned(),
|
service_url: "https://livekit1.com".to_owned(),
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use as_variant::as_variant;
|
use as_variant::as_variant;
|
||||||
use ruma_common::MilliSecondsSinceUnixEpoch;
|
use ruma_common::{DeviceId, MilliSecondsSinceUnixEpoch, OwnedDeviceId};
|
||||||
use ruma_macros::StringEnum;
|
use ruma_macros::StringEnum;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
@ -41,7 +41,7 @@ impl<'a> MembershipData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The device id of this membership.
|
/// The device id of this membership.
|
||||||
pub fn device_id(&self) -> &String {
|
pub fn device_id(&self) -> &DeviceId {
|
||||||
match self {
|
match self {
|
||||||
MembershipData::Legacy(data) => &data.device_id,
|
MembershipData::Legacy(data) => &data.device_id,
|
||||||
MembershipData::Session(data) => &data.device_id,
|
MembershipData::Session(data) => &data.device_id,
|
||||||
@ -121,7 +121,7 @@ pub struct LegacyMembershipData {
|
|||||||
/// The device id of this membership.
|
/// The device id of this membership.
|
||||||
///
|
///
|
||||||
/// The same user can join with their phone/computer.
|
/// The same user can join with their phone/computer.
|
||||||
pub device_id: String,
|
pub device_id: OwnedDeviceId,
|
||||||
|
|
||||||
/// The duration in milliseconds relative to the time this membership joined
|
/// The duration in milliseconds relative to the time this membership joined
|
||||||
/// during which the membership is valid.
|
/// during which the membership is valid.
|
||||||
@ -190,7 +190,7 @@ pub struct LegacyMembershipDataInit {
|
|||||||
/// The device id of this membership.
|
/// The device id of this membership.
|
||||||
///
|
///
|
||||||
/// The same user can join with their phone/computer.
|
/// The same user can join with their phone/computer.
|
||||||
pub device_id: String,
|
pub device_id: OwnedDeviceId,
|
||||||
|
|
||||||
/// The duration in milliseconds relative to the time this membership joined
|
/// The duration in milliseconds relative to the time this membership joined
|
||||||
/// during which the membership is valid.
|
/// during which the membership is valid.
|
||||||
@ -236,7 +236,7 @@ pub struct SessionMembershipData {
|
|||||||
/// The device id of this membership.
|
/// The device id of this membership.
|
||||||
///
|
///
|
||||||
/// The same user can join with their phone/computer.
|
/// The same user can join with their phone/computer.
|
||||||
pub device_id: String,
|
pub device_id: OwnedDeviceId,
|
||||||
|
|
||||||
/// A list of the foci that this membership proposes to use.
|
/// A list of the foci that this membership proposes to use.
|
||||||
pub foci_preferred: Vec<Focus>,
|
pub foci_preferred: Vec<Focus>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user