events: Include all event type segments in Rust type names

This commit is contained in:
Jonas Platte 2021-10-02 21:25:21 +02:00
parent 4e4b71bcdd
commit 04080085f9
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
71 changed files with 535 additions and 509 deletions

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members)
use ruma_api::ruma_api;
use ruma_events::room::member::MemberEvent;
use ruma_events::room::member::RoomMemberEvent;
use ruma_identifiers::RoomId;
use ruma_serde::{Raw, StringEnum};
@ -42,7 +42,7 @@ ruma_api! {
response: {
/// A list of member events.
pub chunk: Vec<Raw<MemberEvent>>,
pub chunk: Vec<Raw<RoomMemberEvent>>,
}
error: crate::Error
@ -57,7 +57,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given member event chunk.
pub fn new(chunk: Vec<Raw<MemberEvent>>) -> Self {
pub fn new(chunk: Vec<Raw<RoomMemberEvent>>) -> Self {
Self { chunk }
}
}

View File

@ -6,8 +6,8 @@ use ruma_api::ruma_api;
use ruma_events::room::create::RoomType;
use ruma_events::{
room::{
create::{CreateEventContent, PreviousRoom},
power_levels::PowerLevelsEventContent,
create::{PreviousRoom, RoomCreateEventContent},
power_levels::RoomPowerLevelsEventContent,
},
AnyInitialStateEvent,
};
@ -61,7 +61,7 @@ ruma_api! {
/// Power level content to override in the default power level event.
#[serde(skip_serializing_if = "Option::is_none")]
pub power_level_content_override: Option<Raw<PowerLevelsEventContent>>,
pub power_level_content_override: Option<Raw<RoomPowerLevelsEventContent>>,
/// Convenience parameter for setting various default state events based on a preset.
#[serde(skip_serializing_if = "Option::is_none")]
@ -151,14 +151,14 @@ impl CreationContent {
}
/// Given a `CreationContent` and the other fields that a homeserver has to fill, construct
/// a `CreateEventContent`.
/// a `RoomCreateEventContent`.
pub fn into_event_content(
self,
creator: UserId,
room_version: RoomVersionId,
) -> CreateEventContent {
) -> RoomCreateEventContent {
#[allow(unused_mut)]
let mut content = assign!(CreateEventContent::new(creator), {
let mut content = assign!(RoomCreateEventContent::new(creator), {
federate: self.federate,
room_version: room_version,
predecessor: self.predecessor,

View File

@ -458,7 +458,7 @@ fn expand_redact_event(
fn redact(
self,
redaction: #ruma_events::room::redaction::SyncRedactionEvent,
redaction: #ruma_events::room::redaction::SyncRoomRedactionEvent,
version: &#ruma_identifiers::RoomVersionId,
) -> Self::Redacted {
let content = #ruma_events::RedactContent::redact(self.content, version);

View File

@ -332,7 +332,7 @@ fn generate_event_type_aliases(
ruma_events: &TokenStream,
) -> syn::Result<TokenStream> {
// The redaction module has its own event types.
if ident == "RedactionEventContent" {
if ident == "RoomRedactionEventContent" {
return Ok(quote! {});
}
@ -394,7 +394,7 @@ fn generate_marker_trait_impl(
EventKind::Message => quote! { MessageEventContent },
EventKind::State => quote! { StateEventContent },
EventKind::ToDevice => quote! { ToDeviceEventContent },
EventKind::Redaction | EventKind::Presence | EventKind::Decrypted => {
EventKind::RoomRedaction | EventKind::Presence | EventKind::Decrypted => {
return Err(syn::Error::new_spanned(
ident,
"valid event kinds are GlobalAccountData, RoomAccountData, \
@ -454,7 +454,7 @@ fn generate_static_event_content_impl(
EventKind::Message => quote! { Message { redacted: #redacted } },
EventKind::State => quote! { State { redacted: #redacted } },
EventKind::ToDevice => quote! { ToDevice },
EventKind::Redaction | EventKind::Presence | EventKind::Decrypted => {
EventKind::RoomRedaction | EventKind::Presence | EventKind::Decrypted => {
unreachable!("not a valid event content kind")
}
};

View File

@ -475,7 +475,7 @@ fn expand_redact(
fn redact(
self,
redaction: #ruma_events::room::redaction::SyncRedactionEvent,
redaction: #ruma_events::room::redaction::SyncRoomRedactionEvent,
version: &#ruma_identifiers::RoomVersionId,
) -> #redacted_enum {
match self {
@ -729,9 +729,8 @@ fn to_event_path(
let path: Vec<_> = name[2..].split('.').collect();
let event_str = path.last().unwrap();
let event: String = event_str
.split('_')
let event: String = name[2..]
.split(&['.', '_'] as &[char])
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
.collect();
@ -760,9 +759,8 @@ fn to_event_content_path(
let path: Vec<_> = name[2..].split('.').collect();
let event_str = path.last().unwrap();
let event: String = event_str
.split('_')
let event: String = name[2..]
.split(&['.', '_'] as &[char])
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
.collect();

View File

@ -79,7 +79,7 @@ pub enum EventKind {
Message,
State,
ToDevice,
Redaction,
RoomRedaction,
Presence,
Decrypted,
}
@ -93,7 +93,7 @@ impl fmt::Display for EventKind {
EventKind::Message => write!(f, "MessageEvent"),
EventKind::State => write!(f, "StateEvent"),
EventKind::ToDevice => write!(f, "ToDeviceEvent"),
EventKind::Redaction => write!(f, "RedactionEvent"),
EventKind::RoomRedaction => write!(f, "RoomRedactionEvent"),
EventKind::Presence => write!(f, "PresenceEvent"),
EventKind::Decrypted => unreachable!(),
}
@ -133,10 +133,10 @@ impl EventKind {
| (Self::State, V::Stripped)
| (Self::State, V::Initial)
| (Self::Message, V::Redacted)
| (Self::Redaction, V::Redacted)
| (Self::RoomRedaction, V::Redacted)
| (Self::State, V::Redacted)
| (Self::Message, V::RedactedSync)
| (Self::Redaction, V::RedactedSync)
| (Self::RoomRedaction, V::RedactedSync)
| (Self::State, V::RedactedSync) => Some(format_ident!("{}{}", var, self)),
_ => None,
}
@ -203,11 +203,13 @@ pub fn to_kind_variation(ident: &Ident) -> Option<(EventKind, EventKindVariation
"RedactedSyncStateEvent" => Some((EventKind::State, EventKindVariation::RedactedSync)),
"ToDeviceEvent" => Some((EventKind::ToDevice, EventKindVariation::Full)),
"PresenceEvent" => Some((EventKind::Presence, EventKindVariation::Full)),
"RedactionEvent" => Some((EventKind::Redaction, EventKindVariation::Full)),
"SyncRedactionEvent" => Some((EventKind::Redaction, EventKindVariation::Sync)),
"RedactedRedactionEvent" => Some((EventKind::Redaction, EventKindVariation::Redacted)),
"RedactedSyncRedactionEvent" => {
Some((EventKind::Redaction, EventKindVariation::RedactedSync))
"RoomRedactionEvent" => Some((EventKind::RoomRedaction, EventKindVariation::Full)),
"SyncRoomRedactionEvent" => Some((EventKind::RoomRedaction, EventKindVariation::Sync)),
"RedactedRoomRedactionEvent" => {
Some((EventKind::RoomRedaction, EventKindVariation::Redacted))
}
"RedactedSyncRoomRedactionEvent" => {
Some((EventKind::RoomRedaction, EventKindVariation::RedactedSync))
}
"DecryptedOlmV1Event" | "DecryptedMegolmV1Event" => {
Some((EventKind::Decrypted, EventKindVariation::Full))

View File

@ -31,7 +31,7 @@ pub fn expand_event_type_enum(
room.push(&event.events);
}
EventKind::ToDevice => to_device.push(&event.events),
EventKind::Redaction | EventKind::Presence | EventKind::Decrypted => {}
EventKind::RoomRedaction | EventKind::Presence | EventKind::Decrypted => {}
}
}
let presence = vec![EventEnumEntry {

View File

@ -9,7 +9,7 @@
#[cfg(feature = "criterion")]
use criterion::{criterion_group, criterion_main, Criterion};
use ruma_events::{
room::power_levels::PowerLevelsEventContent, AnyRoomEvent, AnyStateEvent, StateEvent,
room::power_levels::RoomPowerLevelsEventContent, AnyRoomEvent, AnyStateEvent, StateEvent,
};
use ruma_serde::Raw;
use serde_json::json;
@ -75,8 +75,9 @@ fn deserialize_specific_event(c: &mut Criterion) {
c.bench_function("deserialize to `StateEvent<PowerLevelsEventContent>`", |b| {
b.iter(|| {
let _ =
serde_json::from_value::<StateEvent<PowerLevelsEventContent>>(json_data.clone())
let _ = serde_json::from_value::<StateEvent<RoomPowerLevelsEventContent>>(
json_data.clone(),
)
.unwrap();
})
});

View File

@ -12,7 +12,7 @@ use super::SessionDescription;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.answer", kind = Message)]
pub struct AnswerEventContent {
pub struct CallAnswerEventContent {
/// The VoIP session description object. The session description type must be *answer*.
pub answer: SessionDescription,
@ -23,7 +23,7 @@ pub struct AnswerEventContent {
pub version: UInt,
}
impl AnswerEventContent {
impl CallAnswerEventContent {
/// Creates an `AnswerEventContent` with the given answer, call ID and VoIP version.
pub fn new(answer: SessionDescription, call_id: String, version: UInt) -> Self {
Self { answer, call_id, version }

View File

@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.candidates", kind = Message)]
pub struct CandidatesEventContent {
pub struct CallCandidatesEventContent {
/// The ID of the call this event relates to.
pub call_id: String,
@ -22,7 +22,7 @@ pub struct CandidatesEventContent {
pub version: UInt,
}
impl CandidatesEventContent {
impl CallCandidatesEventContent {
/// Creates a new `CandidatesEventContent` with the given call id, candidate list and VoIP
/// version.
pub fn new(call_id: String, candidates: Vec<Candidate>, version: UInt) -> Self {

View File

@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.hangup", kind = Message)]
pub struct HangupEventContent {
pub struct CallHangupEventContent {
/// The ID of the call this event relates to.
pub call_id: String,
@ -24,7 +24,7 @@ pub struct HangupEventContent {
pub reason: Option<Reason>,
}
impl HangupEventContent {
impl CallHangupEventContent {
/// Creates a new `HangupEventContent` with the given call ID and VoIP version.
pub fn new(call_id: String, version: UInt) -> Self {
Self { call_id, version, reason: None }

View File

@ -12,7 +12,7 @@ use super::SessionDescription;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.invite", kind = Message)]
pub struct InviteEventContent {
pub struct CallInviteEventContent {
/// A unique identifier for the call.
pub call_id: String,
@ -28,7 +28,7 @@ pub struct InviteEventContent {
pub version: UInt,
}
impl InviteEventContent {
impl CallInviteEventContent {
/// Creates a new `InviteEventContent` with the given call ID, lifetime and VoIP version.
pub fn new(call_id: String, lifetime: UInt, offer: SessionDescription, version: UInt) -> Self {
Self { call_id, lifetime, offer, version }

View File

@ -4,7 +4,9 @@ use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
use serde::{de, Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
use crate::{from_raw_json_value, room::redaction::SyncRedactionEvent, Redact, UnsignedDeHelper};
use crate::{
from_raw_json_value, room::redaction::SyncRoomRedactionEvent, Redact, UnsignedDeHelper,
};
event_enum! {
/// Any global account data event.
@ -281,7 +283,7 @@ impl Redact for AnyRoomEvent {
/// Redacts `self`, referencing the given event in `unsigned.redacted_because`.
///
/// Does nothing for events that are already redacted.
fn redact(self, redaction: SyncRedactionEvent, version: &RoomVersionId) -> Self::Redacted {
fn redact(self, redaction: SyncRoomRedactionEvent, version: &RoomVersionId) -> Self::Redacted {
match self {
Self::Message(ev) => Self::Redacted::Message(ev.redact(redaction, version)),
Self::State(ev) => Self::Redacted::State(ev.redact(redaction, version)),
@ -317,7 +319,7 @@ impl Redact for AnySyncRoomEvent {
/// Redacts `self`, referencing the given event in `unsigned.redacted_because`.
///
/// Does nothing for events that are already redacted.
fn redact(self, redaction: SyncRedactionEvent, version: &RoomVersionId) -> Self::Redacted {
fn redact(self, redaction: SyncRoomRedactionEvent, version: &RoomVersionId) -> Self::Redacted {
match self {
Self::Message(ev) => Self::Redacted::Message(ev.redact(redaction, version)),
Self::State(ev) => Self::Redacted::State(ev.redact(redaction, version)),
@ -344,21 +346,22 @@ impl AnyMessageEventContent {
pub fn relation(&self) -> Option<crate::room::encrypted::Relation> {
#[cfg(feature = "unstable-pre-spec")]
use crate::key::verification::{
accept::AcceptEventContent, cancel::CancelEventContent, done::DoneEventContent,
key::KeyEventContent, mac::MacEventContent, ready::ReadyEventContent,
start::StartEventContent,
accept::KeyVerificationAcceptEventContent, cancel::KeyVerificationCancelEventContent,
done::KeyVerificationDoneEventContent, key::KeyVerificationKeyEventContent,
mac::KeyVerificationMacEventContent, ready::KeyVerificationReadyEventContent,
start::KeyVerificationStartEventContent,
};
match self {
#[cfg(feature = "unstable-pre-spec")]
#[rustfmt::skip]
AnyMessageEventContent::KeyVerificationReady(ReadyEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationStart(StartEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationCancel(CancelEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationAccept(AcceptEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationKey(KeyEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationMac(MacEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationDone(DoneEventContent { relates_to, .. }) => {
AnyMessageEventContent::KeyVerificationReady(KeyVerificationReadyEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationStart(KeyVerificationStartEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationCancel(KeyVerificationCancelEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationAccept(KeyVerificationAcceptEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationKey(KeyVerificationKeyEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationMac(KeyVerificationMacEventContent { relates_to, .. })
| AnyMessageEventContent::KeyVerificationDone(KeyVerificationDoneEventContent { relates_to, .. }) => {
Some(relates_to.clone().into())
},
#[cfg(feature = "unstable-pre-spec")]

View File

@ -18,7 +18,7 @@ use super::{
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.accept", kind = ToDevice)]
pub struct ToDeviceAcceptEventContent {
pub struct ToDeviceKeyVerificationAcceptEventContent {
/// An opaque identifier for the verification process.
///
/// Must be the same as the one used for the `m.key.verification.start` message.
@ -29,9 +29,9 @@ pub struct ToDeviceAcceptEventContent {
pub method: AcceptMethod,
}
impl ToDeviceAcceptEventContent {
/// Creates a new `ToDeviceAcceptEventContent` with the given transaction ID and method-specific
/// content.
impl ToDeviceKeyVerificationAcceptEventContent {
/// Creates a new `ToDeviceKeyVerificationAcceptEventContent` with the given transaction ID and
/// method-specific content.
pub fn new(transaction_id: String, method: AcceptMethod) -> Self {
Self { transaction_id, method }
}
@ -45,7 +45,7 @@ impl ToDeviceAcceptEventContent {
#[cfg(feature = "unstable-pre-spec")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct AcceptEventContent {
pub struct KeyVerificationAcceptEventContent {
/// The method specific content.
#[serde(flatten)]
pub method: AcceptMethod,
@ -56,9 +56,9 @@ pub struct AcceptEventContent {
}
#[cfg(feature = "unstable-pre-spec")]
impl AcceptEventContent {
/// Creates a new `ToDeviceAcceptEventContent` with the given method-specific content and
/// relation.
impl KeyVerificationAcceptEventContent {
/// Creates a new `ToDeviceKeyVerificationAcceptEventContent` with the given method-specific
/// content and relation.
pub fn new(method: AcceptMethod, relates_to: Relation) -> Self {
Self { method, relates_to }
}
@ -174,10 +174,10 @@ mod tests {
};
#[cfg(feature = "unstable-pre-spec")]
use super::AcceptEventContent;
use super::KeyVerificationAcceptEventContent;
use super::{
AcceptMethod, HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, SasV1Content,
ShortAuthenticationString, ToDeviceAcceptEventContent, _CustomContent,
ShortAuthenticationString, ToDeviceKeyVerificationAcceptEventContent, _CustomContent,
};
#[cfg(feature = "unstable-pre-spec")]
use crate::key::verification::Relation;
@ -185,7 +185,7 @@ mod tests {
#[test]
fn serialization() {
let key_verification_accept_content = ToDeviceAcceptEventContent {
let key_verification_accept_content = ToDeviceKeyVerificationAcceptEventContent {
transaction_id: "456".into(),
method: AcceptMethod::SasV1(SasV1Content {
hash: HashAlgorithm::Sha256,
@ -229,7 +229,7 @@ mod tests {
"type": "m.key.verification.accept"
});
let key_verification_accept_content = ToDeviceAcceptEventContent {
let key_verification_accept_content = ToDeviceKeyVerificationAcceptEventContent {
transaction_id: "456".into(),
method: AcceptMethod::_Custom(_CustomContent {
method: "m.sas.custom".to_owned(),
@ -250,7 +250,7 @@ mod tests {
fn in_room_serialization() {
let event_id = event_id!("$1598361704261elfgc:localhost");
let key_verification_accept_content = AcceptEventContent {
let key_verification_accept_content = KeyVerificationAcceptEventContent {
relates_to: Relation { event_id: event_id.clone() },
method: AcceptMethod::SasV1(SasV1Content {
hash: HashAlgorithm::Sha256,
@ -291,8 +291,8 @@ mod tests {
// Deserialize the content struct separately to verify `TryFromRaw` is implemented for it.
assert_matches!(
from_json_value::<ToDeviceAcceptEventContent>(json).unwrap(),
ToDeviceAcceptEventContent {
from_json_value::<ToDeviceKeyVerificationAcceptEventContent>(json).unwrap(),
ToDeviceKeyVerificationAcceptEventContent {
transaction_id,
method: AcceptMethod::SasV1(SasV1Content {
commitment,
@ -326,10 +326,10 @@ mod tests {
});
assert_matches!(
from_json_value::<ToDeviceEvent<ToDeviceAcceptEventContent>>(json).unwrap(),
from_json_value::<ToDeviceEvent<ToDeviceKeyVerificationAcceptEventContent>>(json).unwrap(),
ToDeviceEvent {
sender,
content: ToDeviceAcceptEventContent {
content: ToDeviceKeyVerificationAcceptEventContent {
transaction_id,
method: AcceptMethod::SasV1(SasV1Content {
commitment,
@ -362,10 +362,10 @@ mod tests {
});
assert_matches!(
from_json_value::<ToDeviceEvent<ToDeviceAcceptEventContent>>(json).unwrap(),
from_json_value::<ToDeviceEvent<ToDeviceKeyVerificationAcceptEventContent>>(json).unwrap(),
ToDeviceEvent {
sender,
content: ToDeviceAcceptEventContent {
content: ToDeviceKeyVerificationAcceptEventContent {
transaction_id,
method: AcceptMethod::_Custom(_CustomContent {
method,
@ -399,8 +399,8 @@ mod tests {
// Deserialize the content struct separately to verify `TryFromRaw` is implemented for it.
assert_matches!(
from_json_value::<AcceptEventContent>(json).unwrap(),
AcceptEventContent {
from_json_value::<KeyVerificationAcceptEventContent>(json).unwrap(),
KeyVerificationAcceptEventContent {
relates_to: Relation {
event_id
},

View File

@ -13,7 +13,7 @@ use super::Relation;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.cancel", kind = ToDevice)]
pub struct ToDeviceCancelEventContent {
pub struct ToDeviceKeyVerificationCancelEventContent {
/// The opaque identifier for the verification process/request.
pub transaction_id: String,
@ -26,8 +26,9 @@ pub struct ToDeviceCancelEventContent {
pub code: CancelCode,
}
impl ToDeviceCancelEventContent {
/// Creates a new `ToDeviceCancelEventContent` with the given transaction ID, reason and code.
impl ToDeviceKeyVerificationCancelEventContent {
/// Creates a new `ToDeviceKeyVerificationCancelEventContent` with the given transaction ID,
/// reason and code.
pub fn new(transaction_id: String, reason: String, code: CancelCode) -> Self {
Self { transaction_id, reason, code }
}
@ -41,7 +42,7 @@ impl ToDeviceCancelEventContent {
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.cancel", kind = Message)]
pub struct CancelEventContent {
pub struct KeyVerificationCancelEventContent {
/// A human readable description of the `code`.
///
/// The client should only rely on this string if it does not understand the `code`.
@ -56,8 +57,8 @@ pub struct CancelEventContent {
}
#[cfg(feature = "unstable-pre-spec")]
impl CancelEventContent {
/// Creates a new `CancelEventContent` with the given reason, code and relation.
impl KeyVerificationCancelEventContent {
/// Creates a new `KeyVerificationCancelEventContent` with the given reason, code and relation.
pub fn new(reason: String, code: CancelCode, relates_to: Relation) -> Self {
Self { reason, code, relates_to }
}

View File

@ -11,15 +11,15 @@ use super::Relation;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.done", kind = ToDevice)]
pub struct ToDeviceDoneEventContent {
pub struct ToDeviceKeyVerificationDoneEventContent {
/// An opaque identifier for the verification process.
///
/// Must be the same as the one used for the `m.key.verification.start` message.
pub transaction_id: String,
}
impl ToDeviceDoneEventContent {
/// Creates a new `ToDeviceDoneEventContent` with the given transaction ID.
impl ToDeviceKeyVerificationDoneEventContent {
/// Creates a new `ToDeviceKeyVerificationDoneEventContent` with the given transaction ID.
pub fn new(transaction_id: String) -> Self {
Self { transaction_id }
}
@ -31,14 +31,14 @@ impl ToDeviceDoneEventContent {
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.done", kind = Message)]
pub struct DoneEventContent {
pub struct KeyVerificationDoneEventContent {
/// Relation signaling which verification request this event is responding to.
#[serde(rename = "m.relates_to")]
pub relates_to: Relation,
}
impl DoneEventContent {
/// Creates a new `DoneEventContent` with the given relation.
impl KeyVerificationDoneEventContent {
/// Creates a new `KeyVerificationDoneEventContent` with the given relation.
pub fn new(relates_to: Relation) -> Self {
Self { relates_to }
}
@ -50,7 +50,7 @@ mod tests {
use ruma_identifiers::event_id;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::DoneEventContent;
use super::KeyVerificationDoneEventContent;
use crate::key::verification::Relation;
#[test]
@ -64,7 +64,7 @@ mod tests {
}
});
let content = DoneEventContent { relates_to: Relation { event_id } };
let content = KeyVerificationDoneEventContent { relates_to: Relation { event_id } };
assert_eq!(to_json_value(&content).unwrap(), json_data);
}
@ -81,8 +81,8 @@ mod tests {
});
assert_matches!(
from_json_value::<DoneEventContent>(json_data).unwrap(),
DoneEventContent {
from_json_value::<KeyVerificationDoneEventContent>(json_data).unwrap(),
KeyVerificationDoneEventContent {
relates_to: Relation {
event_id
},

View File

@ -12,7 +12,7 @@ use super::Relation;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.key", kind = ToDevice)]
pub struct ToDeviceKeyEventContent {
pub struct ToDeviceKeyVerificationKeyEventContent {
/// An opaque identifier for the verification process.
///
/// Must be the same as the one used for the `m.key.verification.start` message.
@ -22,8 +22,9 @@ pub struct ToDeviceKeyEventContent {
pub key: String,
}
impl ToDeviceKeyEventContent {
/// Creates a new `ToDeviceKeyEventContent` with the given transaction ID and key.
impl ToDeviceKeyVerificationKeyEventContent {
/// Creates a new `ToDeviceKeyVerificationKeyEventContent` with the given transaction ID and
/// key.
pub fn new(transaction_id: String, key: String) -> Self {
Self { transaction_id, key }
}
@ -37,7 +38,7 @@ impl ToDeviceKeyEventContent {
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.key", kind = Message)]
pub struct KeyEventContent {
pub struct KeyVerificationKeyEventContent {
/// The device's ephemeral public key, encoded as unpadded Base64.
pub key: String,
@ -47,8 +48,8 @@ pub struct KeyEventContent {
}
#[cfg(feature = "unstable-pre-spec")]
impl KeyEventContent {
/// Creates a new `KeyEventContent` with the given key and relation.
impl KeyVerificationKeyEventContent {
/// Creates a new `KeyVerificationKeyEventContent` with the given key and relation.
pub fn new(key: String, relates_to: Relation) -> Self {
Self { key, relates_to }
}

View File

@ -14,7 +14,7 @@ use super::Relation;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.mac", kind = ToDevice)]
pub struct ToDeviceMacEventContent {
pub struct ToDeviceKeyVerificationMacEventContent {
/// An opaque identifier for the verification process.
///
/// Must be the same as the one used for the `m.key.verification.start` message.
@ -30,9 +30,9 @@ pub struct ToDeviceMacEventContent {
pub keys: String,
}
impl ToDeviceMacEventContent {
/// Creates a new `ToDeviceMacEventContent` with the given transaction ID, key ID to MAC map and
/// key MAC.
impl ToDeviceKeyVerificationMacEventContent {
/// Creates a new `ToDeviceKeyVerificationMacEventContent` with the given transaction ID, key ID
/// to MAC map and key MAC.
pub fn new(transaction_id: String, mac: BTreeMap<String, String>, keys: String) -> Self {
Self { transaction_id, mac, keys }
}
@ -46,7 +46,7 @@ impl ToDeviceMacEventContent {
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.mac", kind = Message)]
pub struct MacEventContent {
pub struct KeyVerificationMacEventContent {
/// A map of the key ID to the MAC of the key, using the algorithm in the verification process.
///
/// The MAC is encoded as unpadded Base64.
@ -62,8 +62,9 @@ pub struct MacEventContent {
}
#[cfg(feature = "unstable-pre-spec")]
impl MacEventContent {
/// Creates a new `MacEventContent` with the given key ID to MAC map, key MAC and relation.
impl KeyVerificationMacEventContent {
/// Creates a new `KeyVerificationMacEventContent` with the given key ID to MAC map, key MAC and
/// relation.
pub fn new(mac: BTreeMap<String, String>, keys: String, relates_to: Relation) -> Self {
Self { mac, keys, relates_to }
}

View File

@ -12,7 +12,7 @@ use super::{Relation, VerificationMethod};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.ready", kind = ToDevice)]
pub struct ToDeviceReadyEventContent {
pub struct ToDeviceKeyVerificationReadyEventContent {
/// The device ID which is initiating the request.
pub from_device: DeviceIdBox,
@ -27,9 +27,9 @@ pub struct ToDeviceReadyEventContent {
pub transaction_id: String,
}
impl ToDeviceReadyEventContent {
/// Creates a new `ToDeviceReadyEventContent` with the given device ID, verification methods and
/// transaction ID.
impl ToDeviceKeyVerificationReadyEventContent {
/// Creates a new `ToDeviceKeyVerificationReadyEventContent` with the given device ID,
/// verification methods and transaction ID.
pub fn new(
from_device: DeviceIdBox,
methods: Vec<VerificationMethod>,
@ -45,7 +45,7 @@ impl ToDeviceReadyEventContent {
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.ready", kind = Message)]
pub struct ReadyEventContent {
pub struct KeyVerificationReadyEventContent {
/// The device ID which is initiating the request.
pub from_device: DeviceIdBox,
@ -58,8 +58,9 @@ pub struct ReadyEventContent {
pub relates_to: Relation,
}
impl ReadyEventContent {
/// Creates a new `ReadyEventContent` with the given device ID, methods and relation.
impl KeyVerificationReadyEventContent {
/// Creates a new `KeyVerificationReadyEventContent` with the given device ID, methods and
/// relation.
pub fn new(
from_device: DeviceIdBox,
methods: Vec<VerificationMethod>,
@ -75,7 +76,7 @@ mod tests {
use ruma_identifiers::{event_id, DeviceIdBox};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{ReadyEventContent, ToDeviceReadyEventContent};
use super::{KeyVerificationReadyEventContent, ToDeviceKeyVerificationReadyEventContent};
use crate::key::verification::{Relation, VerificationMethod};
#[test]
@ -92,7 +93,7 @@ mod tests {
}
});
let content = ReadyEventContent {
let content = KeyVerificationReadyEventContent {
from_device: device.clone(),
relates_to: Relation { event_id },
methods: vec![VerificationMethod::SasV1],
@ -106,7 +107,7 @@ mod tests {
"transaction_id": "456",
});
let content = ToDeviceReadyEventContent {
let content = ToDeviceKeyVerificationReadyEventContent {
from_device: device,
transaction_id: "456".to_owned(),
methods: vec![VerificationMethod::SasV1],
@ -130,8 +131,8 @@ mod tests {
});
assert_matches!(
from_json_value::<ReadyEventContent>(json_data).unwrap(),
ReadyEventContent {
from_json_value::<KeyVerificationReadyEventContent>(json_data).unwrap(),
KeyVerificationReadyEventContent {
from_device,
relates_to: Relation {
event_id
@ -149,8 +150,8 @@ mod tests {
});
assert_matches!(
from_json_value::<ToDeviceReadyEventContent>(json_data).unwrap(),
ToDeviceReadyEventContent {
from_json_value::<ToDeviceKeyVerificationReadyEventContent>(json_data).unwrap(),
ToDeviceKeyVerificationReadyEventContent {
from_device,
transaction_id,
methods,

View File

@ -11,7 +11,7 @@ use super::VerificationMethod;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.request", kind = ToDevice)]
pub struct ToDeviceRequestEventContent {
pub struct ToDeviceKeyVerificationRequestEventContent {
/// The device ID which is initiating the request.
pub from_device: DeviceIdBox,
@ -30,9 +30,9 @@ pub struct ToDeviceRequestEventContent {
pub timestamp: MilliSecondsSinceUnixEpoch,
}
impl ToDeviceRequestEventContent {
/// Creates a new `ToDeviceRequestEventContent` with the given device ID, transaction ID,
/// methods and timestamp.
impl ToDeviceKeyVerificationRequestEventContent {
/// Creates a new `ToDeviceKeyVerificationRequestEventContent` with the given device ID,
/// transaction ID, methods and timestamp.
pub fn new(
from_device: DeviceIdBox,
transaction_id: String,

View File

@ -19,7 +19,7 @@ use super::{
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.start", kind = ToDevice)]
pub struct ToDeviceStartEventContent {
pub struct ToDeviceKeyVerificationStartEventContent {
/// The device ID which is initiating the process.
pub from_device: DeviceIdBox,
@ -35,9 +35,9 @@ pub struct ToDeviceStartEventContent {
pub method: StartMethod,
}
impl ToDeviceStartEventContent {
/// Creates a new `ToDeviceStartEventContent` with the given device ID, transaction ID and
/// method specific content.
impl ToDeviceKeyVerificationStartEventContent {
/// Creates a new `ToDeviceKeyVerificationStartEventContent` with the given device ID,
/// transaction ID and method specific content.
pub fn new(from_device: DeviceIdBox, transaction_id: String, method: StartMethod) -> Self {
Self { from_device, transaction_id, method }
}
@ -51,7 +51,7 @@ impl ToDeviceStartEventContent {
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.key.verification.start", kind = Message)]
pub struct StartEventContent {
pub struct KeyVerificationStartEventContent {
/// The device ID which is initiating the process.
pub from_device: DeviceIdBox,
@ -65,8 +65,9 @@ pub struct StartEventContent {
}
#[cfg(feature = "unstable-pre-spec")]
impl StartEventContent {
/// Creates a new `StartEventContent` with the given device ID, method and relation.
impl KeyVerificationStartEventContent {
/// Creates a new `KeyVerificationStartEventContent` with the given device ID, method and
/// relation.
pub fn new(from_device: DeviceIdBox, method: StartMethod, relates_to: Relation) -> Self {
Self { from_device, method, relates_to }
}
@ -209,18 +210,18 @@ mod tests {
use super::{
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, SasV1Content,
SasV1ContentInit, ShortAuthenticationString, StartMethod, ToDeviceStartEventContent,
_CustomContent,
SasV1ContentInit, ShortAuthenticationString, StartMethod,
ToDeviceKeyVerificationStartEventContent, _CustomContent,
};
#[cfg(feature = "unstable-pre-spec")]
use super::{ReciprocateV1Content, StartEventContent};
use super::{KeyVerificationStartEventContent, ReciprocateV1Content};
#[cfg(feature = "unstable-pre-spec")]
use crate::key::verification::Relation;
use crate::ToDeviceEvent;
#[test]
fn serialization() {
let key_verification_start_content = ToDeviceStartEventContent {
let key_verification_start_content = ToDeviceKeyVerificationStartEventContent {
from_device: "123".into(),
transaction_id: "456".into(),
method: StartMethod::SasV1(
@ -268,7 +269,7 @@ mod tests {
"sender": sender
});
let key_verification_start_content = ToDeviceStartEventContent {
let key_verification_start_content = ToDeviceKeyVerificationStartEventContent {
from_device: "123".into(),
transaction_id: "456".into(),
method: StartMethod::_Custom(_CustomContent {
@ -288,7 +289,7 @@ mod tests {
{
let secret = "This is a secret to everybody".to_owned();
let key_verification_start_content = ToDeviceStartEventContent {
let key_verification_start_content = ToDeviceKeyVerificationStartEventContent {
from_device: "123".into(),
transaction_id: "456".into(),
method: StartMethod::ReciprocateV1(ReciprocateV1Content::new(secret.clone())),
@ -310,7 +311,7 @@ mod tests {
fn in_room_serialization() {
let event_id = event_id!("$1598361704261elfgc:localhost");
let key_verification_start_content = StartEventContent {
let key_verification_start_content = KeyVerificationStartEventContent {
from_device: "123".into(),
relates_to: Relation { event_id: event_id.clone() },
method: StartMethod::SasV1(
@ -341,7 +342,7 @@ mod tests {
let secret = "This is a secret to everybody".to_owned();
let key_verification_start_content = StartEventContent {
let key_verification_start_content = KeyVerificationStartEventContent {
from_device: "123".into(),
relates_to: Relation { event_id: event_id.clone() },
method: StartMethod::ReciprocateV1(ReciprocateV1Content::new(secret.clone())),
@ -374,8 +375,8 @@ mod tests {
// Deserialize the content struct separately to verify `TryFromRaw` is implemented for it.
assert_matches!(
from_json_value::<ToDeviceStartEventContent>(json).unwrap(),
ToDeviceStartEventContent {
from_json_value::<ToDeviceKeyVerificationStartEventContent>(json).unwrap(),
ToDeviceKeyVerificationStartEventContent {
from_device,
transaction_id,
method: StartMethod::SasV1(SasV1Content {
@ -409,10 +410,10 @@ mod tests {
});
assert_matches!(
from_json_value::<ToDeviceEvent<ToDeviceStartEventContent>>(json).unwrap(),
from_json_value::<ToDeviceEvent<ToDeviceKeyVerificationStartEventContent>>(json).unwrap(),
ToDeviceEvent {
sender,
content: ToDeviceStartEventContent {
content: ToDeviceKeyVerificationStartEventContent {
from_device,
transaction_id,
method: StartMethod::SasV1(SasV1Content {
@ -445,10 +446,10 @@ mod tests {
});
assert_matches!(
from_json_value::<ToDeviceEvent<ToDeviceStartEventContent>>(json).unwrap(),
from_json_value::<ToDeviceEvent<ToDeviceKeyVerificationStartEventContent>>(json).unwrap(),
ToDeviceEvent {
sender,
content: ToDeviceStartEventContent {
content: ToDeviceKeyVerificationStartEventContent {
from_device,
transaction_id,
method: StartMethod::_Custom(_CustomContent { method, data })
@ -474,10 +475,10 @@ mod tests {
});
assert_matches!(
from_json_value::<ToDeviceEvent<ToDeviceStartEventContent>>(json).unwrap(),
from_json_value::<ToDeviceEvent<ToDeviceKeyVerificationStartEventContent>>(json).unwrap(),
ToDeviceEvent {
sender,
content: ToDeviceStartEventContent {
content: ToDeviceKeyVerificationStartEventContent {
from_device,
transaction_id,
method: StartMethod::ReciprocateV1(ReciprocateV1Content { secret }),
@ -510,8 +511,8 @@ mod tests {
// Deserialize the content struct separately to verify `TryFromRaw` is implemented for it.
assert_matches!(
from_json_value::<StartEventContent>(json).unwrap(),
StartEventContent {
from_json_value::<KeyVerificationStartEventContent>(json).unwrap(),
KeyVerificationStartEventContent {
from_device,
relates_to: Relation { event_id },
method: StartMethod::SasV1(SasV1Content {
@ -539,8 +540,8 @@ mod tests {
});
assert_matches!(
from_json_value::<StartEventContent>(json).unwrap(),
StartEventContent {
from_json_value::<KeyVerificationStartEventContent>(json).unwrap(),
KeyVerificationStartEventContent {
from_device,
relates_to: Relation { event_id },
method: StartMethod::ReciprocateV1(ReciprocateV1Content { secret }),

View File

@ -125,7 +125,7 @@ use serde::{
};
use serde_json::value::RawValue as RawJsonValue;
use self::room::redaction::SyncRedactionEvent;
use self::room::redaction::SyncRoomRedactionEvent;
mod enums;
mod event_kinds;
@ -220,7 +220,7 @@ pub trait Redact {
///
/// A small number of events have room-version specific redaction behavior, so a version has to
/// be specified.
fn redact(self, redaction: SyncRedactionEvent, version: &RoomVersionId) -> Self::Redacted;
fn redact(self, redaction: SyncRoomRedactionEvent, version: &RoomVersionId) -> Self::Redacted;
}
/// Trait to define the behavior of redact an event's content object.

View File

@ -11,7 +11,7 @@ use crate::policy::rule::PolicyRuleEventContent;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[allow(clippy::exhaustive_structs)]
#[ruma_event(type = "m.policy.rule.room", kind = State)]
pub struct RoomEventContent(pub PolicyRuleEventContent);
pub struct PolicyRuleRoomEventContent(pub PolicyRuleEventContent);
#[cfg(test)]
mod tests {
@ -23,7 +23,7 @@ mod tests {
use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{RoomEvent, RoomEventContent};
use super::{PolicyRuleRoomEvent, PolicyRuleRoomEventContent};
use crate::{
policy::rule::{PolicyRuleEventContent, Recommendation},
Unsigned,
@ -31,7 +31,7 @@ mod tests {
#[test]
fn serialization() {
let room_event = RoomEvent {
let room_event = PolicyRuleRoomEvent {
event_id: event_id!("$143273582443PhrSn:example.org"),
sender: user_id!("@example:example.org"),
origin_server_ts: MilliSecondsSinceUnixEpoch(1_432_735_824_653_u64.try_into().unwrap()),
@ -44,7 +44,7 @@ mod tests {
#[cfg(feature = "unstable-pre-spec")]
relations: None,
},
content: RoomEventContent(PolicyRuleEventContent {
content: PolicyRuleRoomEventContent(PolicyRuleEventContent {
entity: "#*:example.org".into(),
reason: "undesirable content".into(),
recommendation: Recommendation::Ban,
@ -90,6 +90,6 @@ mod tests {
}
});
assert!(from_json_value::<Raw<RoomEvent>>(json).unwrap().deserialize().is_ok());
assert!(from_json_value::<Raw<PolicyRuleRoomEvent>>(json).unwrap().deserialize().is_ok());
}
}

View File

@ -11,4 +11,4 @@ use crate::policy::rule::PolicyRuleEventContent;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[allow(clippy::exhaustive_structs)]
#[ruma_event(type = "m.policy.rule.server", kind = State)]
pub struct ServerEventContent(pub PolicyRuleEventContent);
pub struct PolicyRuleServerEventContent(pub PolicyRuleEventContent);

View File

@ -11,4 +11,4 @@ use crate::policy::rule::PolicyRuleEventContent;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[allow(clippy::exhaustive_structs)]
#[ruma_event(type = "m.policy.rule.user", kind = State)]
pub struct UserEventContent(pub PolicyRuleEventContent);
pub struct PolicyRuleUserEventContent(pub PolicyRuleEventContent);

View File

@ -16,22 +16,22 @@ use crate::{
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.aliases", kind = State, custom_redacted)]
pub struct AliasesEventContent {
pub struct RoomAliasesEventContent {
/// A list of room aliases.
pub aliases: Vec<RoomAliasId>,
}
impl AliasesEventContent {
/// Create an `AliasesEventContent` from the given aliases.
impl RoomAliasesEventContent {
/// Create an `RoomAliasesEventContent` from the given aliases.
pub fn new(aliases: Vec<RoomAliasId>) -> Self {
Self { aliases }
}
}
impl RedactContent for AliasesEventContent {
type Redacted = RedactedAliasesEventContent;
impl RedactContent for RoomAliasesEventContent {
type Redacted = RedactedRoomAliasesEventContent;
fn redact(self, version: &RoomVersionId) -> RedactedAliasesEventContent {
fn redact(self, version: &RoomVersionId) -> RedactedRoomAliasesEventContent {
// We compare the long way to avoid pre version 6 behavior if/when
// a new room version is introduced.
let aliases = match version {
@ -43,14 +43,14 @@ impl RedactContent for AliasesEventContent {
_ => None,
};
RedactedAliasesEventContent { aliases }
RedactedRoomAliasesEventContent { aliases }
}
}
/// An aliases event that has been redacted.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RedactedAliasesEventContent {
pub struct RedactedRoomAliasesEventContent {
/// A list of room aliases.
///
/// According to the Matrix spec version 1 redaction rules allowed this field to be
@ -58,7 +58,7 @@ pub struct RedactedAliasesEventContent {
pub aliases: Option<Vec<RoomAliasId>>,
}
impl RedactedAliasesEventContent {
impl RedactedRoomAliasesEventContent {
/// Create a `RedactedAliasesEventContent` with the given aliases.
///
/// This is only valid for room version 5 and below.
@ -74,7 +74,7 @@ impl RedactedAliasesEventContent {
}
}
impl EventContent for RedactedAliasesEventContent {
impl EventContent for RedactedRoomAliasesEventContent {
fn event_type(&self) -> &str {
"m.room.aliases"
}
@ -93,7 +93,7 @@ impl EventContent for RedactedAliasesEventContent {
// Since this redacted event has fields we leave the default `empty` method
// that will error if called.
impl RedactedEventContent for RedactedAliasesEventContent {
impl RedactedEventContent for RedactedRoomAliasesEventContent {
fn has_serialize_fields(&self) -> bool {
self.aliases.is_some()
}
@ -103,4 +103,4 @@ impl RedactedEventContent for RedactedAliasesEventContent {
}
}
impl RedactedStateEventContent for RedactedAliasesEventContent {}
impl RedactedStateEventContent for RedactedRoomAliasesEventContent {}

View File

@ -16,7 +16,7 @@ use super::ThumbnailInfo;
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[cfg_attr(feature = "unstable-pre-spec", derive(Default))]
#[ruma_event(type = "m.room.avatar", kind = State)]
pub struct AvatarEventContent {
pub struct RoomAvatarEventContent {
/// Information about the avatar image.
#[serde(skip_serializing_if = "Option::is_none")]
pub info: Option<Box<ImageInfo>>,
@ -34,8 +34,8 @@ pub struct AvatarEventContent {
pub url: Option<MxcUri>,
}
impl AvatarEventContent {
/// Create an `AvatarEventContent` from the given image URL.
impl RoomAvatarEventContent {
/// Create an `RoomAvatarEventContent` from the given image URL.
///
/// With the `unstable-pre-spec` feature, this method takes no parameters.
#[cfg(not(feature = "unstable-pre-spec"))]
@ -43,7 +43,7 @@ impl AvatarEventContent {
Self { info: None, url }
}
/// Create an empty `AvatarEventContent`.
/// Create an empty `RoomAvatarEventContent`.
///
/// With the `unstable-pre-spec` feature, this method takes an `MxcUri`.
#[cfg(feature = "unstable-pre-spec")]

View File

@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.canonical_alias", kind = State)]
pub struct CanonicalAliasEventContent {
pub struct RoomCanonicalAliasEventContent {
/// The canonical alias.
///
/// Rooms with `alias: None` should be treated the same as a room
@ -27,8 +27,8 @@ pub struct CanonicalAliasEventContent {
pub alt_aliases: Vec<RoomAliasId>,
}
impl CanonicalAliasEventContent {
/// Creates an empty `CanonicalAliasEventContent`.
impl RoomCanonicalAliasEventContent {
/// Creates an empty `RoomCanonicalAliasEventContent`.
pub fn new() -> Self {
Self { alias: None, alt_aliases: Vec::new() }
}
@ -41,13 +41,13 @@ mod tests {
use ruma_identifiers::{event_id, room_alias_id, room_id, user_id};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::CanonicalAliasEventContent;
use super::RoomCanonicalAliasEventContent;
use crate::{StateEvent, Unsigned};
#[test]
fn serialization_with_optional_fields_as_none() {
let canonical_alias_event = StateEvent {
content: CanonicalAliasEventContent {
content: RoomCanonicalAliasEventContent {
alias: Some(room_alias_id!("#somewhere:localhost")),
alt_aliases: Vec::new(),
},
@ -89,7 +89,7 @@ mod tests {
});
assert_eq!(
from_json_value::<StateEvent<CanonicalAliasEventContent>>(json_data)
from_json_value::<StateEvent<RoomCanonicalAliasEventContent>>(json_data)
.unwrap()
.content
.alias,
@ -111,7 +111,7 @@ mod tests {
"type": "m.room.canonical_alias"
});
assert_eq!(
from_json_value::<StateEvent<CanonicalAliasEventContent>>(json_data)
from_json_value::<StateEvent<RoomCanonicalAliasEventContent>>(json_data)
.unwrap()
.content
.alias,
@ -133,7 +133,7 @@ mod tests {
"type": "m.room.canonical_alias"
});
assert_eq!(
from_json_value::<StateEvent<CanonicalAliasEventContent>>(json_data)
from_json_value::<StateEvent<RoomCanonicalAliasEventContent>>(json_data)
.unwrap()
.content
.alias,
@ -156,7 +156,7 @@ mod tests {
"type": "m.room.canonical_alias"
});
assert_eq!(
from_json_value::<StateEvent<CanonicalAliasEventContent>>(json_data)
from_json_value::<StateEvent<RoomCanonicalAliasEventContent>>(json_data)
.unwrap()
.content
.alias,

View File

@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.create", kind = State)]
pub struct CreateEventContent {
pub struct RoomCreateEventContent {
/// The `user_id` of the room creator. This is set by the homeserver.
#[ruma_event(skip_redaction)]
pub creator: UserId,
@ -42,8 +42,8 @@ pub struct CreateEventContent {
pub room_type: Option<RoomType>,
}
impl CreateEventContent {
/// Creates a new `CreateEventContent` with the given creator.
impl RoomCreateEventContent {
/// Creates a new `RoomCreateEventContent` with the given creator.
pub fn new(creator: UserId) -> Self {
Self {
creator,
@ -107,14 +107,14 @@ mod tests {
use ruma_identifiers::{user_id, RoomVersionId};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::CreateEventContent;
use super::RoomCreateEventContent;
#[cfg(feature = "unstable-pre-spec")]
use super::RoomType;
#[test]
fn serialization() {
let content = CreateEventContent {
let content = RoomCreateEventContent {
creator: user_id!("@carl:example.com"),
federate: false,
room_version: RoomVersionId::Version4,
@ -135,7 +135,7 @@ mod tests {
#[cfg(feature = "unstable-pre-spec")]
#[test]
fn space_serialization() {
let content = CreateEventContent {
let content = RoomCreateEventContent {
creator: user_id!("@carl:example.com"),
federate: false,
room_version: RoomVersionId::Version4,
@ -162,8 +162,8 @@ mod tests {
});
assert_matches!(
from_json_value::<CreateEventContent>(json).unwrap(),
CreateEventContent {
from_json_value::<RoomCreateEventContent>(json).unwrap(),
RoomCreateEventContent {
creator,
federate: true,
room_version: RoomVersionId::Version4,
@ -185,8 +185,8 @@ mod tests {
});
assert_matches!(
from_json_value::<CreateEventContent>(json).unwrap(),
CreateEventContent {
from_json_value::<RoomCreateEventContent>(json).unwrap(),
RoomCreateEventContent {
creator,
federate: true,
room_version: RoomVersionId::Version4,

View File

@ -19,7 +19,7 @@ mod relation_serde;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.encrypted", kind = Message, kind = ToDevice)]
pub struct EncryptedEventContent {
pub struct RoomEncryptedEventContent {
/// Algorithm-specific fields.
#[serde(flatten)]
pub scheme: EncryptedEventScheme,
@ -31,14 +31,14 @@ pub struct EncryptedEventContent {
pub relates_to: Option<Relation>,
}
impl EncryptedEventContent {
/// Creates a new `EncryptedEventContent` with the given scheme and relation.
impl RoomEncryptedEventContent {
/// Creates a new `RoomEncryptedEventContent` with the given scheme and relation.
pub fn new(scheme: EncryptedEventScheme, relates_to: Option<Relation>) -> Self {
Self { scheme, relates_to }
}
}
impl From<EncryptedEventScheme> for EncryptedEventContent {
impl From<EncryptedEventScheme> for RoomEncryptedEventContent {
fn from(scheme: EncryptedEventScheme) -> Self {
Self { scheme, relates_to: None }
}
@ -48,26 +48,26 @@ impl From<EncryptedEventScheme> for EncryptedEventContent {
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.encrypted", kind = ToDevice)]
pub struct ToDeviceEncryptedEventContent {
pub struct ToDeviceRoomEncryptedEventContent {
/// Algorithm-specific fields.
#[serde(flatten)]
pub scheme: EncryptedEventScheme,
}
impl ToDeviceEncryptedEventContent {
/// Creates a new `ToDeviceEncryptedEventContent` with the given scheme.
impl ToDeviceRoomEncryptedEventContent {
/// Creates a new `ToDeviceRoomEncryptedEventContent` with the given scheme.
pub fn new(scheme: EncryptedEventScheme) -> Self {
Self { scheme }
}
}
impl From<EncryptedEventScheme> for ToDeviceEncryptedEventContent {
impl From<EncryptedEventScheme> for ToDeviceRoomEncryptedEventContent {
fn from(scheme: EncryptedEventScheme) -> Self {
Self { scheme }
}
}
/// The encryption scheme for `EncryptedEventContent`.
/// The encryption scheme for `RoomEncryptedEventContent`.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(tag = "algorithm")]
@ -288,13 +288,15 @@ mod tests {
use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{EncryptedEventContent, EncryptedEventScheme, MegolmV1AesSha2Content, Relation};
use super::{
EncryptedEventScheme, MegolmV1AesSha2Content, Relation, RoomEncryptedEventContent,
};
use crate::room::message::InReplyTo;
use ruma_identifiers::event_id;
#[test]
fn serialization() {
let key_verification_start_content = EncryptedEventContent {
let key_verification_start_content = RoomEncryptedEventContent {
scheme: EncryptedEventScheme::MegolmV1AesSha2(MegolmV1AesSha2Content {
ciphertext: "ciphertext".into(),
sender_key: "sender_key".into(),
@ -337,7 +339,7 @@ mod tests {
},
});
let content: EncryptedEventContent = from_json_value(json_data).unwrap();
let content: RoomEncryptedEventContent = from_json_value(json_data).unwrap();
assert_matches!(
content.scheme,
@ -371,7 +373,7 @@ mod tests {
},
"algorithm": "m.olm.v1.curve25519-aes-sha2"
});
let content: EncryptedEventContent = from_json_value(json_data).unwrap();
let content: RoomEncryptedEventContent = from_json_value(json_data).unwrap();
match content.scheme {
EncryptedEventScheme::OlmV1Curve25519AesSha2(c) => {
@ -386,7 +388,7 @@ mod tests {
#[test]
fn deserialization_failure() {
assert!(from_json_value::<Raw<EncryptedEventContent>>(
assert!(from_json_value::<Raw<RoomEncryptedEventContent>>(
json!({ "algorithm": "m.megolm.v1.aes-sha2" })
)
.unwrap()

View File

@ -12,7 +12,7 @@ use crate::EventEncryptionAlgorithm;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.encryption", kind = State)]
pub struct EncryptionEventContent {
pub struct RoomEncryptionEventContent {
/// The encryption algorithm to be used to encrypt messages sent in this room.
///
/// Must be `m.megolm.v1.aes-sha2`.
@ -31,8 +31,8 @@ pub struct EncryptionEventContent {
pub rotation_period_msgs: Option<UInt>,
}
impl EncryptionEventContent {
/// Creates a new `EncryptionEventContent` with the given algorithm.
impl RoomEncryptionEventContent {
/// Creates a new `RoomEncryptionEventContent` with the given algorithm.
pub fn new(algorithm: EventEncryptionAlgorithm) -> Self {
Self { algorithm, rotation_period_ms: None, rotation_period_msgs: None }
}

View File

@ -13,13 +13,13 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.guest_access", kind = State)]
pub struct GuestAccessEventContent {
pub struct RoomGuestAccessEventContent {
/// A policy for guest user access to a room.
pub guest_access: GuestAccess,
}
impl GuestAccessEventContent {
/// Creates a new `GuestAccessEventContent` with the given policy.
impl RoomGuestAccessEventContent {
/// Creates a new `RoomGuestAccessEventContent` with the given policy.
pub fn new(guest_access: GuestAccess) -> Self {
Self { guest_access }
}

View File

@ -11,14 +11,14 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.history_visibility", kind = State)]
pub struct HistoryVisibilityEventContent {
pub struct RoomHistoryVisibilityEventContent {
/// Who can see the room history.
#[ruma_event(skip_redaction)]
pub history_visibility: HistoryVisibility,
}
impl HistoryVisibilityEventContent {
/// Creates a new `HistoryVisibilityEventContent` with the given policy.
impl RoomHistoryVisibilityEventContent {
/// Creates a new `RoomHistoryVisibilityEventContent` with the given policy.
pub fn new(history_visibility: HistoryVisibility) -> Self {
Self { history_visibility }
}

View File

@ -22,34 +22,34 @@ use std::collections::BTreeMap;
#[derive(Clone, Debug, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.join_rules", kind = State)]
pub struct JoinRulesEventContent {
pub struct RoomJoinRulesEventContent {
/// The type of rules used for users wishing to join this room.
#[ruma_event(skip_redaction)]
#[serde(flatten)]
pub join_rule: JoinRule,
}
impl JoinRulesEventContent {
/// Creates a new `JoinRulesEventContent` with the given rule.
impl RoomJoinRulesEventContent {
/// Creates a new `RoomJoinRulesEventContent` with the given rule.
pub fn new(join_rule: JoinRule) -> Self {
Self { join_rule }
}
/// Creates a new `JoinRulesEventContent` with the restricted rule and the given set of allow
/// rules.
/// Creates a new `RoomJoinRulesEventContent` with the restricted rule and the given set of
/// allow rules.
#[cfg(feature = "unstable-pre-spec")]
pub fn restricted(allow: Vec<AllowRule>) -> Self {
Self { join_rule: JoinRule::Restricted(Restricted::new(allow)) }
}
}
impl<'de> Deserialize<'de> for JoinRulesEventContent {
impl<'de> Deserialize<'de> for RoomJoinRulesEventContent {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let join_rule = JoinRule::deserialize(deserializer)?;
Ok(JoinRulesEventContent { join_rule })
Ok(RoomJoinRulesEventContent { join_rule })
}
}
@ -241,15 +241,15 @@ impl<'de> Deserialize<'de> for AllowRule {
mod tests {
#[cfg(feature = "unstable-pre-spec")]
use super::AllowRule;
use super::{JoinRule, JoinRulesEventContent};
use super::{JoinRule, RoomJoinRulesEventContent};
#[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::room_id;
#[test]
fn deserialize() {
let json = r#"{"join_rule": "public"}"#;
let event: JoinRulesEventContent = serde_json::from_str(json).unwrap();
assert!(matches!(event, JoinRulesEventContent { join_rule: JoinRule::Public }));
let event: RoomJoinRulesEventContent = serde_json::from_str(json).unwrap();
assert!(matches!(event, RoomJoinRulesEventContent { join_rule: JoinRule::Public }));
}
#[cfg(feature = "unstable-pre-spec")]
@ -268,7 +268,7 @@ mod tests {
}
]
}"#;
let event: JoinRulesEventContent = serde_json::from_str(json).unwrap();
let event: RoomJoinRulesEventContent = serde_json::from_str(json).unwrap();
match event.join_rule {
JoinRule::Restricted(restricted) => assert_eq!(
restricted.allow,

View File

@ -39,7 +39,7 @@ use crate::{StrippedStateEvent, SyncStateEvent};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.member", kind = State)]
pub struct MemberEventContent {
pub struct RoomMemberEventContent {
/// The avatar URL for this user, if any. This is added by the homeserver.
///
/// If you activate the `compat` feature, this field being an empty string in JSON will give
@ -95,8 +95,8 @@ pub struct MemberEventContent {
pub reason: Option<String>,
}
impl MemberEventContent {
/// Creates a new `MemberEventContent` with the given membership state.
impl RoomMemberEventContent {
/// Creates a new `RoomMemberEventContent` with the given membership state.
pub fn new(membership: MembershipState) -> Self {
Self {
membership,
@ -246,11 +246,11 @@ pub enum MembershipChange {
NotImplemented,
}
/// Internal function so all `MemberEventContent` state event kinds can share the same
/// Internal function so all `RoomMemberEventContent` state event kinds can share the same
/// implementation.
fn membership_change(
content: &MemberEventContent,
prev_content: Option<&MemberEventContent>,
content: &RoomMemberEventContent,
prev_content: Option<&RoomMemberEventContent>,
sender: &UserId,
state_key: &str,
) -> MembershipChange {
@ -260,7 +260,7 @@ fn membership_change(
let prev_content = if let Some(prev_content) = &prev_content {
prev_content
} else {
&MemberEventContent {
&RoomMemberEventContent {
avatar_url: None,
displayname: None,
is_direct: None,
@ -303,7 +303,7 @@ fn membership_change(
}
}
impl MemberEvent {
impl RoomMemberEvent {
/// Helper function for membership change. Check [the specification][spec] for details.
///
/// [spec]: https://matrix.org/docs/spec/client_server/r0.6.1#m-room-member
@ -312,7 +312,7 @@ impl MemberEvent {
}
}
impl SyncStateEvent<MemberEventContent> {
impl SyncStateEvent<RoomMemberEventContent> {
/// Helper function for membership change. Check [the specification][spec] for details.
///
/// [spec]: https://matrix.org/docs/spec/client_server/r0.6.1#m-room-member
@ -321,7 +321,7 @@ impl SyncStateEvent<MemberEventContent> {
}
}
impl StrippedStateEvent<MemberEventContent> {
impl StrippedStateEvent<RoomMemberEventContent> {
/// Helper function for membership change. Check [the specification][spec] for details.
///
/// [spec]: https://matrix.org/docs/spec/client_server/r0.6.1#m-room-member
@ -339,7 +339,7 @@ mod tests {
use ruma_identifiers::{server_name, server_signing_key_id};
use serde_json::{from_value as from_json_value, json};
use super::{MemberEventContent, MembershipState, SignedContent, ThirdPartyInvite};
use super::{MembershipState, RoomMemberEventContent, SignedContent, ThirdPartyInvite};
use crate::StateEvent;
#[test]
@ -357,9 +357,9 @@ mod tests {
});
assert_matches!(
from_json_value::<StateEvent<MemberEventContent>>(json).unwrap(),
from_json_value::<StateEvent<RoomMemberEventContent>>(json).unwrap(),
StateEvent {
content: MemberEventContent {
content: RoomMemberEventContent {
avatar_url: None,
displayname: None,
is_direct: None,
@ -401,9 +401,9 @@ mod tests {
});
assert_matches!(
from_json_value::<StateEvent<MemberEventContent>>(json).unwrap(),
from_json_value::<StateEvent<RoomMemberEventContent>>(json).unwrap(),
StateEvent {
content: MemberEventContent {
content: RoomMemberEventContent {
avatar_url: None,
displayname: None,
is_direct: None,
@ -417,7 +417,7 @@ mod tests {
sender,
state_key,
unsigned,
prev_content: Some(MemberEventContent {
prev_content: Some(RoomMemberEventContent {
avatar_url: None,
displayname: None,
is_direct: None,
@ -464,9 +464,9 @@ mod tests {
});
assert_matches!(
from_json_value::<StateEvent<MemberEventContent>>(json).unwrap(),
from_json_value::<StateEvent<RoomMemberEventContent>>(json).unwrap(),
StateEvent {
content: MemberEventContent {
content: RoomMemberEventContent {
avatar_url: Some(avatar_url),
displayname: Some(displayname),
is_direct: Some(true),
@ -536,9 +536,9 @@ mod tests {
});
assert_matches!(
from_json_value::<StateEvent<MemberEventContent>>(json).unwrap(),
from_json_value::<StateEvent<RoomMemberEventContent>>(json).unwrap(),
StateEvent {
content: MemberEventContent {
content: RoomMemberEventContent {
avatar_url: None,
displayname: None,
is_direct: None,
@ -552,7 +552,7 @@ mod tests {
sender,
state_key,
unsigned,
prev_content: Some(MemberEventContent {
prev_content: Some(RoomMemberEventContent {
avatar_url: Some(avatar_url),
displayname: Some(displayname),
is_direct: Some(true),
@ -583,7 +583,7 @@ mod tests {
#[cfg(feature = "compat")]
assert_matches!(
from_json_value::<StateEvent<MemberEventContent>>(json!({
from_json_value::<StateEvent<RoomMemberEventContent>>(json!({
"type": "m.room.member",
"content": {
"membership": "join"
@ -613,7 +613,7 @@ mod tests {
"state_key": "@alice:example.org"
})).unwrap(),
StateEvent {
content: MemberEventContent {
content: RoomMemberEventContent {
avatar_url: None,
displayname: None,
is_direct: None,
@ -627,7 +627,7 @@ mod tests {
sender,
state_key,
unsigned,
prev_content: Some(MemberEventContent {
prev_content: Some(RoomMemberEventContent {
avatar_url: None,
displayname: Some(displayname),
is_direct: Some(true),

View File

@ -28,7 +28,7 @@ mod relation_serde;
#[derive(Clone, Debug, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.message", kind = Message)]
pub struct MessageEventContent {
pub struct RoomMessageEventContent {
/// A key which identifies the type of message being sent.
///
/// This also holds the specific content of each message.
@ -42,8 +42,8 @@ pub struct MessageEventContent {
pub relates_to: Option<Relation>,
}
impl MessageEventContent {
/// Create a `MessageEventContent` with the given `MessageType`.
impl RoomMessageEventContent {
/// Create a `RoomMessageEventContent` with the given `MessageType`.
pub fn new(msgtype: MessageType) -> Self {
Self { msgtype, relates_to: None }
}
@ -69,7 +69,7 @@ impl MessageEventContent {
}
/// Creates a plain text reply to a message.
pub fn text_reply_plain(reply: impl Into<String>, original_message: &MessageEvent) -> Self {
pub fn text_reply_plain(reply: impl Into<String>, original_message: &RoomMessageEvent) -> Self {
let quoted = get_plain_quote_fallback(original_message);
let body = format!("{}\n\n{}", quoted, reply.into());
@ -86,7 +86,7 @@ impl MessageEventContent {
pub fn text_reply_html(
reply: impl Into<String>,
html_reply: impl Into<String>,
original_message: &MessageEvent,
original_message: &RoomMessageEvent,
) -> Self {
let quoted = get_plain_quote_fallback(original_message);
let quoted_html = get_html_quote_fallback(original_message);
@ -103,7 +103,10 @@ impl MessageEventContent {
}
/// Creates a plain text notice reply to a message.
pub fn notice_reply_plain(reply: impl Into<String>, original_message: &MessageEvent) -> Self {
pub fn notice_reply_plain(
reply: impl Into<String>,
original_message: &RoomMessageEvent,
) -> Self {
let quoted = get_plain_quote_fallback(original_message);
let body = format!("{}\n\n{}", quoted, reply.into());
@ -119,7 +122,7 @@ impl MessageEventContent {
pub fn notice_reply_html(
reply: impl Into<String>,
html_reply: impl Into<String>,
original_message: &MessageEvent,
original_message: &RoomMessageEvent,
) -> Self {
let quoted = get_plain_quote_fallback(original_message);
let quoted_html = get_html_quote_fallback(original_message);
@ -287,7 +290,7 @@ impl MessageType {
}
}
impl From<MessageType> for MessageEventContent {
impl From<MessageType> for RoomMessageEventContent {
fn from(msgtype: MessageType) -> Self {
Self::new(msgtype)
}
@ -340,13 +343,13 @@ pub struct Replacement {
pub event_id: EventId,
/// New content.
pub new_content: Box<MessageEventContent>,
pub new_content: Box<RoomMessageEventContent>,
}
#[cfg(feature = "unstable-pre-spec")]
impl Replacement {
/// Creates a new `Replacement` with the given event ID and new content.
pub fn new(event_id: EventId, new_content: Box<MessageEventContent>) -> Self {
pub fn new(event_id: EventId, new_content: Box<RoomMessageEventContent>) -> Self {
Self { event_id, new_content }
}
}
@ -377,13 +380,14 @@ pub struct AudioMessageEventContent {
}
impl AudioMessageEventContent {
/// Creates a new non-encrypted `AudioMessageEventContent` with the given body, url and optional
/// extra info.
/// Creates a new non-encrypted `RoomAudioMessageEventContent` with the given body, url and
/// optional extra info.
pub fn plain(body: String, url: MxcUri, info: Option<Box<AudioInfo>>) -> Self {
Self { body, url: Some(url), info, file: None }
}
/// Creates a new encrypted `AudioMessageEventContent` with the given body and encrypted file.
/// Creates a new encrypted `RoomAudioMessageEventContent` with the given body and encrypted
/// file.
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self { body, url: None, info: None, file: Some(Box::new(file)) }
}
@ -478,13 +482,14 @@ pub struct FileMessageEventContent {
}
impl FileMessageEventContent {
/// Creates a new non-encrypted `FileMessageEventContent` with the given body, url and optional
/// extra info.
/// Creates a new non-encrypted `RoomFileMessageEventContent` with the given body, url and
/// optional extra info.
pub fn plain(body: String, url: MxcUri, info: Option<Box<FileInfo>>) -> Self {
Self { body, filename: None, url: Some(url), info, file: None }
}
/// Creates a new encrypted `FileMessageEventContent` with the given body and encrypted file.
/// Creates a new encrypted `RoomFileMessageEventContent` with the given body and encrypted
/// file.
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self { body, filename: None, url: None, info: None, file: Some(Box::new(file)) }
}
@ -553,13 +558,14 @@ pub struct ImageMessageEventContent {
}
impl ImageMessageEventContent {
/// Creates a new non-encrypted `ImageMessageEventContent` with the given body, url and optional
/// extra info.
/// Creates a new non-encrypted `RoomImageMessageEventContent` with the given body, url and
/// optional extra info.
pub fn plain(body: String, url: MxcUri, info: Option<Box<ImageInfo>>) -> Self {
Self { body, url: Some(url), info, file: None }
}
/// Creates a new encrypted `ImageMessageEventContent` with the given body and encrypted file.
/// Creates a new encrypted `RoomImageMessageEventContent` with the given body and encrypted
/// file.
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self { body, url: None, info: None, file: Some(Box::new(file)) }
}
@ -583,7 +589,7 @@ pub struct LocationMessageEventContent {
}
impl LocationMessageEventContent {
/// Creates a new `LocationMessageEventContent` with the given body and geo URI.
/// Creates a new `RoomLocationMessageEventContent` with the given body and geo URI.
pub fn new(body: String, geo_uri: String) -> Self {
Self { body, geo_uri, info: None }
}
@ -677,7 +683,7 @@ pub struct ServerNoticeMessageEventContent {
}
impl ServerNoticeMessageEventContent {
/// Creates a new `ServerNoticeMessageEventContent` with the given body and notice type.
/// Creates a new `RoomServerNoticeMessageEventContent` with the given body and notice type.
pub fn new(body: String, server_notice_type: ServerNoticeType) -> Self {
Self { body, server_notice_type, admin_contact: None, limit_type: None }
}
@ -846,13 +852,14 @@ pub struct VideoMessageEventContent {
}
impl VideoMessageEventContent {
/// Creates a new non-encrypted `VideoMessageEventContent` with the given body, url and optional
/// extra info.
/// Creates a new non-encrypted `RoomVideoMessageEventContent` with the given body, url and
/// optional extra info.
pub fn plain(body: String, url: MxcUri, info: Option<Box<VideoInfo>>) -> Self {
Self { body, url: Some(url), info, file: None }
}
/// Creates a new encrypted `VideoMessageEventContent` with the given body and encrypted file.
/// Creates a new encrypted `RoomVideoMessageEventContent` with the given body and encrypted
/// file.
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self { body, url: None, info: None, file: Some(Box::new(file)) }
}
@ -945,8 +952,8 @@ pub struct KeyVerificationRequestEventContent {
#[cfg(feature = "unstable-pre-spec")]
impl KeyVerificationRequestEventContent {
/// Creates a new `KeyVerificationRequestEventContent` with the given body, method, device and
/// user ID.
/// Creates a new `RoomKeyVerificationRequestEventContent` with the given body, method, device
/// and user ID.
pub fn new(
body: String,
methods: Vec<VerificationMethod>,
@ -972,7 +979,7 @@ pub struct CustomEventContent {
data: JsonObject,
}
fn get_plain_quote_fallback(original_message: &MessageEvent) -> String {
fn get_plain_quote_fallback(original_message: &RoomMessageEvent) -> String {
match &original_message.content.msgtype {
MessageType::Audio(_) => {
format!("> <{:?}> sent an audio file.", original_message.sender)
@ -1013,7 +1020,7 @@ fn get_plain_quote_fallback(original_message: &MessageEvent) -> String {
}
#[allow(clippy::nonstandard_macro_braces)]
fn get_html_quote_fallback(original_message: &MessageEvent) -> String {
fn get_html_quote_fallback(original_message: &RoomMessageEvent) -> String {
match &original_message.content.msgtype {
MessageType::Audio(_) => {
formatdoc!(
@ -1228,7 +1235,7 @@ mod tests {
use ruma_identifiers::{event_id, EventId, RoomId, UserId};
use serde_json::{from_value as from_json_value, json};
use super::{InReplyTo, MessageEvent, MessageEventContent, MessageType, Relation};
use super::{InReplyTo, MessageType, Relation, RoomMessageEvent, RoomMessageEventContent};
#[test]
fn deserialize_reply() {
@ -1245,8 +1252,8 @@ mod tests {
});
assert_matches!(
from_json_value::<MessageEventContent>(json).unwrap(),
MessageEventContent {
from_json_value::<RoomMessageEventContent>(json).unwrap(),
RoomMessageEventContent {
msgtype: MessageType::Text(_),
relates_to: Some(Relation::Reply { in_reply_to: InReplyTo { event_id } }),
} if event_id == ev_id
@ -1257,8 +1264,8 @@ mod tests {
fn plain_quote_fallback_multiline() {
let sender = UserId::try_from("@alice:example.com").unwrap();
assert_eq!(
super::get_plain_quote_fallback(&MessageEvent {
content: MessageEventContent::text_plain("multi\nline"),
super::get_plain_quote_fallback(&RoomMessageEvent {
content: RoomMessageEventContent::text_plain("multi\nline"),
event_id: EventId::new(sender.server_name()),
sender,
origin_server_ts: ruma_common::MilliSecondsSinceUnixEpoch::now(),

View File

@ -1,12 +1,12 @@
//! `Deserialize` implementation for MessageEventContent and MessageType.
//! `Deserialize` implementation for RoomMessageEventContent and MessageType.
use serde::{de, Deserialize};
use serde_json::value::RawValue as RawJsonValue;
use super::{MessageEventContent, MessageType, Relation};
use super::{MessageType, Relation, RoomMessageEventContent};
use crate::from_raw_json_value;
impl<'de> Deserialize<'de> for MessageEventContent {
impl<'de> Deserialize<'de> for RoomMessageEventContent {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: de::Deserializer<'de>,

View File

@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.message.feedback", kind = Message)]
pub struct FeedbackEventContent {
pub struct RoomMessageFeedbackEventContent {
/// The event that this feedback is related to.
pub target_event_id: EventId,
@ -23,8 +23,8 @@ pub struct FeedbackEventContent {
pub feedback_type: FeedbackType,
}
impl FeedbackEventContent {
/// Create a `FeedbackEventContent` from the given target event id and feedback type.
impl RoomMessageFeedbackEventContent {
/// Create a `RoomFeedbackEventContent` from the given target event id and feedback type.
pub fn new(target_event_id: EventId, feedback_type: FeedbackType) -> Self {
Self { target_event_id, feedback_type }
}

View File

@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use super::Replacement;
use super::{InReplyTo, Relation};
#[cfg(feature = "unstable-pre-spec")]
use crate::room::message::MessageEventContent;
use crate::room::message::RoomMessageEventContent;
impl<'de> Deserialize<'de> for Relation {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
@ -74,7 +74,7 @@ struct EventWithRelatesToJsonRepr {
#[cfg(feature = "unstable-pre-spec")]
#[serde(rename = "m.new_content", skip_serializing_if = "Option::is_none")]
new_content: Option<Box<MessageEventContent>>,
new_content: Option<Box<RoomMessageEventContent>>,
}
impl EventWithRelatesToJsonRepr {

View File

@ -10,14 +10,14 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(type = "m.room.name", kind = State)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct NameEventContent {
pub struct RoomNameEventContent {
/// The name of the room.
#[serde(default, deserialize_with = "ruma_serde::empty_string_as_none")]
pub name: Option<RoomNameBox>,
}
impl NameEventContent {
/// Create a new `NameEventContent` with the given name.
impl RoomNameEventContent {
/// Create a new `RoomNameEventContent` with the given name.
pub fn new(name: Option<RoomNameBox>) -> Self {
Self { name }
}
@ -34,13 +34,13 @@ mod tests {
use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::NameEventContent;
use super::RoomNameEventContent;
use crate::{StateEvent, Unsigned};
#[test]
fn serialization_with_optional_fields_as_none() {
let name_event = StateEvent {
content: NameEventContent { name: RoomNameBox::try_from("The room name").ok() },
content: RoomNameEventContent { name: RoomNameBox::try_from("The room name").ok() },
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: None,
@ -69,10 +69,10 @@ mod tests {
#[test]
fn serialization_with_all_fields() {
let name_event = StateEvent {
content: NameEventContent { name: RoomNameBox::try_from("The room name").ok() },
content: RoomNameEventContent { name: RoomNameBox::try_from("The room name").ok() },
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: Some(NameEventContent {
prev_content: Some(RoomNameEventContent {
name: RoomNameBox::try_from("The old name").ok(),
}),
room_id: room_id!("!n8f893n9:example.com"),
@ -113,7 +113,7 @@ mod tests {
"type": "m.room.name"
});
assert_eq!(
from_json_value::<StateEvent<NameEventContent>>(json_data).unwrap().content.name,
from_json_value::<StateEvent<RoomNameEventContent>>(json_data).unwrap().content.name,
None
);
}
@ -125,7 +125,7 @@ mod tests {
assert_eq!(long_string.len(), 256);
let long_content_json = json!({ "name": &long_string });
let from_raw: Raw<NameEventContent> = from_json_value(long_content_json).unwrap();
let from_raw: Raw<RoomNameEventContent> = from_json_value(long_content_json).unwrap();
let result = from_raw.deserialize();
assert!(result.is_err(), "Result should be invalid: {:?}", result);
@ -134,15 +134,15 @@ mod tests {
#[test]
fn json_with_empty_name_creates_content_as_none() {
let long_content_json = json!({ "name": "" });
let from_raw: Raw<NameEventContent> = from_json_value(long_content_json).unwrap();
assert_matches!(from_raw.deserialize().unwrap(), NameEventContent { name: None });
let from_raw: Raw<RoomNameEventContent> = from_json_value(long_content_json).unwrap();
assert_matches!(from_raw.deserialize().unwrap(), RoomNameEventContent { name: None });
}
#[test]
fn new_with_empty_name_creates_content_as_none() {
assert_matches!(
NameEventContent::new(RoomNameBox::try_from(String::new()).ok()),
NameEventContent { name: None }
RoomNameEventContent::new(RoomNameBox::try_from(String::new()).ok()),
RoomNameEventContent { name: None }
);
}
@ -160,7 +160,7 @@ mod tests {
"type": "m.room.name"
});
assert_eq!(
from_json_value::<StateEvent<NameEventContent>>(json_data).unwrap().content.name,
from_json_value::<StateEvent<RoomNameEventContent>>(json_data).unwrap().content.name,
None
);
}
@ -179,7 +179,7 @@ mod tests {
"type": "m.room.name"
});
assert_eq!(
from_json_value::<StateEvent<NameEventContent>>(json_data).unwrap().content.name,
from_json_value::<StateEvent<RoomNameEventContent>>(json_data).unwrap().content.name,
None
);
}
@ -200,7 +200,7 @@ mod tests {
});
assert_eq!(
from_json_value::<StateEvent<NameEventContent>>(json_data).unwrap().content.name,
from_json_value::<StateEvent<RoomNameEventContent>>(json_data).unwrap().content.name,
name
);
}

View File

@ -10,13 +10,13 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.pinned_events", kind = State)]
pub struct PinnedEventsEventContent {
pub struct RoomPinnedEventsEventContent {
/// An ordered list of event IDs to pin.
pub pinned: Vec<EventId>,
}
impl PinnedEventsEventContent {
/// Creates a new `PinnedEventsEventContent` with the given events.
impl RoomPinnedEventsEventContent {
/// Creates a new `RoomPinnedEventsEventContent` with the given events.
pub fn new(pinned: Vec<EventId>) -> Self {
Self { pinned }
}
@ -29,12 +29,13 @@ mod tests {
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_identifiers::{server_name, EventId, RoomId, UserId};
use super::PinnedEventsEventContent;
use super::RoomPinnedEventsEventContent;
use crate::{StateEvent, Unsigned};
#[test]
fn serialization_deserialization() {
let mut content: PinnedEventsEventContent = PinnedEventsEventContent { pinned: Vec::new() };
let mut content: RoomPinnedEventsEventContent =
RoomPinnedEventsEventContent { pinned: Vec::new() };
let server_name = server_name!("example.com");
content.pinned.push(EventId::new(&server_name));
@ -52,7 +53,7 @@ mod tests {
};
let serialized_event = serde_json::to_string(&event).unwrap();
let parsed_event: StateEvent<PinnedEventsEventContent> =
let parsed_event: StateEvent<RoomPinnedEventsEventContent> =
serde_json::from_str(&serialized_event).unwrap();
assert_eq!(parsed_event.event_id, event.event_id);

View File

@ -18,7 +18,7 @@ use ruma_common::power_levels::NotificationPowerLevels;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.power_levels", kind = State)]
pub struct PowerLevelsEventContent {
pub struct RoomPowerLevelsEventContent {
/// The level required to ban a user.
///
/// If you activate the `compat` feature, deserialization will work for stringified
@ -116,8 +116,8 @@ pub struct PowerLevelsEventContent {
pub notifications: NotificationPowerLevels,
}
impl PowerLevelsEventContent {
/// Creates a new `PowerLevelsEventContent` with all-default values.
impl RoomPowerLevelsEventContent {
/// Creates a new `RoomPowerLevelsEventContent` with all-default values.
pub fn new() -> Self {
// events_default and users_default having a default of 0 while the others have a default
// of 50 is not an oversight, these defaults are from the Matrix specification.
@ -136,7 +136,7 @@ impl PowerLevelsEventContent {
}
}
impl Default for PowerLevelsEventContent {
impl Default for RoomPowerLevelsEventContent {
fn default() -> Self {
Self::new()
}
@ -159,7 +159,7 @@ mod tests {
use ruma_identifiers::{event_id, room_id, user_id};
use serde_json::{json, to_value as to_json_value};
use super::{default_power_level, NotificationPowerLevels, PowerLevelsEventContent};
use super::{default_power_level, NotificationPowerLevels, RoomPowerLevelsEventContent};
use crate::{EventType, StateEvent, Unsigned};
#[test]
@ -167,7 +167,7 @@ mod tests {
let default = default_power_level();
let power_levels_event = StateEvent {
content: PowerLevelsEventContent {
content: RoomPowerLevelsEventContent {
ban: default,
events: BTreeMap::new(),
events_default: int!(0),
@ -206,7 +206,7 @@ mod tests {
fn serialization_with_all_fields() {
let user = user_id!("@carl:example.com");
let power_levels_event = StateEvent {
content: PowerLevelsEventContent {
content: RoomPowerLevelsEventContent {
ban: int!(23),
events: btreemap! {
EventType::Dummy => int!(23)
@ -224,7 +224,7 @@ mod tests {
},
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: Some(PowerLevelsEventContent {
prev_content: Some(RoomPowerLevelsEventContent {
// Make just one field different so we at least know they're two different objects.
ban: int!(42),
events: btreemap! {

View File

@ -10,9 +10,9 @@ use crate::{Redact, RedactContent, RedactedUnsigned, Unsigned};
/// Redaction event.
#[derive(Clone, Debug, Event)]
#[allow(clippy::exhaustive_structs)]
pub struct RedactionEvent {
pub struct RoomRedactionEvent {
/// Data specific to the event type.
pub content: RedactionEventContent,
pub content: RoomRedactionEventContent,
/// The ID of the event that was redacted.
pub redacts: EventId,
@ -33,15 +33,15 @@ pub struct RedactionEvent {
pub unsigned: Unsigned,
}
impl Redact for RedactionEvent {
type Redacted = RedactedRedactionEvent;
impl Redact for RoomRedactionEvent {
type Redacted = RedactedRoomRedactionEvent;
fn redact(
self,
redaction: SyncRedactionEvent,
redaction: SyncRoomRedactionEvent,
version: &ruma_identifiers::RoomVersionId,
) -> Self::Redacted {
RedactedRedactionEvent {
RedactedRoomRedactionEvent {
content: self.content.redact(version),
// There is no released room version where this isn't redacted yet
redacts: None,
@ -57,9 +57,9 @@ impl Redact for RedactionEvent {
/// Redacted redaction event.
#[derive(Clone, Debug, Event)]
#[allow(clippy::exhaustive_structs)]
pub struct RedactedRedactionEvent {
pub struct RedactedRoomRedactionEvent {
/// Data specific to the event type.
pub content: RedactedRedactionEventContent,
pub content: RedactedRoomRedactionEventContent,
/// The ID of the event that was redacted.
pub redacts: Option<EventId>,
@ -83,9 +83,9 @@ pub struct RedactedRedactionEvent {
/// Redaction event without a `room_id`.
#[derive(Clone, Debug, Event)]
#[allow(clippy::exhaustive_structs)]
pub struct SyncRedactionEvent {
pub struct SyncRoomRedactionEvent {
/// Data specific to the event type.
pub content: RedactionEventContent,
pub content: RoomRedactionEventContent,
/// The ID of the event that was redacted.
pub redacts: EventId,
@ -103,15 +103,15 @@ pub struct SyncRedactionEvent {
pub unsigned: Unsigned,
}
impl Redact for SyncRedactionEvent {
type Redacted = RedactedSyncRedactionEvent;
impl Redact for SyncRoomRedactionEvent {
type Redacted = RedactedSyncRoomRedactionEvent;
fn redact(
self,
redaction: SyncRedactionEvent,
redaction: SyncRoomRedactionEvent,
version: &ruma_identifiers::RoomVersionId,
) -> Self::Redacted {
RedactedSyncRedactionEvent {
RedactedSyncRoomRedactionEvent {
content: self.content.redact(version),
// There is no released room version where this isn't redacted yet
redacts: None,
@ -126,9 +126,9 @@ impl Redact for SyncRedactionEvent {
/// Redacted redaction event without a `room_id`.
#[derive(Clone, Debug, Event)]
#[allow(clippy::exhaustive_structs)]
pub struct RedactedSyncRedactionEvent {
pub struct RedactedSyncRoomRedactionEvent {
/// Data specific to the event type.
pub content: RedactedRedactionEventContent,
pub content: RedactedRoomRedactionEventContent,
/// The ID of the event that was redacted.
pub redacts: Option<EventId>,
@ -150,19 +150,19 @@ pub struct RedactedSyncRedactionEvent {
#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.redaction", kind = Message)]
pub struct RedactionEventContent {
pub struct RoomRedactionEventContent {
/// The reason for the redaction, if any.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
impl RedactionEventContent {
/// Creates an empty `RedactionEventContent`.
impl RoomRedactionEventContent {
/// Creates an empty `RoomRedactionEventContent`.
pub fn new() -> Self {
Self::default()
}
/// Creates a new `RedactionEventContent` with the given reason.
/// Creates a new `RoomRedactionEventContent` with the given reason.
pub fn with_reason(reason: String) -> Self {
Self { reason: Some(reason) }
}

View File

@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.server_acl", kind = State)]
pub struct ServerAclEventContent {
pub struct RoomServerAclEventContent {
/// Whether to allow server names that are IP address literals.
///
/// This is strongly recommended to be set to false as servers running with IP literal names
@ -37,9 +37,9 @@ pub struct ServerAclEventContent {
pub deny: Vec<String>,
}
impl ServerAclEventContent {
/// Creates a new `ServerAclEventContent` with the given IP literal allowance flag, allowed and
/// denied servers.
impl RoomServerAclEventContent {
/// Creates a new `RoomServerAclEventContent` with the given IP literal allowance flag, allowed
/// and denied servers.
pub fn new(allow_ip_literals: bool, allow: Vec<String>, deny: Vec<String>) -> Self {
Self { allow_ip_literals, allow, deny }
}
@ -49,7 +49,7 @@ impl ServerAclEventContent {
mod tests {
use serde_json::{from_value as from_json_value, json};
use super::ServerAclEventContent;
use super::RoomServerAclEventContent;
use crate::StateEvent;
#[test]
@ -64,7 +64,7 @@ mod tests {
"type": "m.room.server_acl"
});
let server_acl_event: StateEvent<ServerAclEventContent> =
let server_acl_event: StateEvent<RoomServerAclEventContent> =
from_json_value(json_data).unwrap();
assert!(server_acl_event.content.allow_ip_literals);

View File

@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.third_party_invite", kind = State)]
pub struct ThirdPartyInviteEventContent {
pub struct RoomThirdPartyInviteEventContent {
/// A user-readable string which represents the user who has been invited.
///
/// If you activate the `compat` feature, this field being absent in JSON will give you an
@ -40,9 +40,9 @@ pub struct ThirdPartyInviteEventContent {
pub public_keys: Option<Vec<PublicKey>>,
}
impl ThirdPartyInviteEventContent {
/// Creates a new `ThirdPartyInviteEventContent` with the given display name, key validity url
/// and public key.
impl RoomThirdPartyInviteEventContent {
/// Creates a new `RoomThirdPartyInviteEventContent` with the given display name, key validity
/// url and public key.
pub fn new(display_name: String, key_validity_url: String, public_key: String) -> Self {
Self { display_name, key_validity_url, public_key, public_keys: None }
}

View File

@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(type = "m.room.tombstone", kind = State)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct TombstoneEventContent {
pub struct RoomTombstoneEventContent {
/// A server-defined message.
///
/// If you activate the `compat` feature, this field being absent in JSON will give you an
@ -23,8 +23,8 @@ pub struct TombstoneEventContent {
pub replacement_room: RoomId,
}
impl TombstoneEventContent {
/// Creates a new `TombstoneEventContent` with the given body and replacement room ID.
impl RoomTombstoneEventContent {
/// Creates a new `RoomTombstoneEventContent` with the given body and replacement room ID.
pub fn new(body: String, replacement_room: RoomId) -> Self {
Self { body, replacement_room }
}

View File

@ -9,13 +9,13 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.topic", kind = State)]
pub struct TopicEventContent {
pub struct RoomTopicEventContent {
/// The topic text.
pub topic: String,
}
impl TopicEventContent {
/// Creates a new `TopicEventContent` with the given topic.
impl RoomTopicEventContent {
/// Creates a new `RoomTopicEventContent` with the given topic.
pub fn new(topic: String) -> Self {
Self { topic }
}

View File

@ -15,7 +15,7 @@ use serde::{ser::SerializeStruct, Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.secret.request", kind = ToDevice)]
pub struct ToDeviceRequestEventContent {
pub struct ToDeviceSecretRequestEventContent {
/// The action for the request.
#[serde(flatten)]
pub action: RequestAction,
@ -31,7 +31,7 @@ pub struct ToDeviceRequestEventContent {
pub request_id: String,
}
impl ToDeviceRequestEventContent {
impl ToDeviceSecretRequestEventContent {
/// Creates a new `ToDeviceRequestEventContent` with the given action, requesting device ID and
/// request ID.
pub fn new(
@ -133,13 +133,13 @@ pub enum SecretName {
#[cfg(test)]
mod test {
use super::{RequestAction, SecretName, ToDeviceRequestEventContent};
use super::{RequestAction, SecretName, ToDeviceSecretRequestEventContent};
use matches::assert_matches;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
#[test]
fn secret_request_serialization() {
let content = ToDeviceRequestEventContent::new(
let content = ToDeviceSecretRequestEventContent::new(
RequestAction::Request("org.example.some.secret".into()),
"ABCDEFG".into(),
"randomly_generated_id_9573".into(),
@ -157,7 +157,7 @@ mod test {
#[test]
fn secret_request_recovery_key_serialization() {
let content = ToDeviceRequestEventContent::new(
let content = ToDeviceSecretRequestEventContent::new(
RequestAction::Request(SecretName::RecoveryKey),
"XYZxyz".into(),
"this_is_a_request_id".into(),
@ -175,7 +175,7 @@ mod test {
#[test]
fn secret_custom_action_serialization() {
let content = ToDeviceRequestEventContent::new(
let content = ToDeviceSecretRequestEventContent::new(
RequestAction::_Custom("my_custom_action".into()),
"XYZxyz".into(),
"this_is_a_request_id".into(),
@ -192,7 +192,7 @@ mod test {
#[test]
fn secret_request_cancellation_serialization() {
let content = ToDeviceRequestEventContent::new(
let content = ToDeviceSecretRequestEventContent::new(
RequestAction::RequestCancellation,
"ABCDEFG".into(),
"randomly_generated_id_9573".into(),
@ -218,7 +218,7 @@ mod test {
assert_matches!(
from_json_value(json).unwrap(),
ToDeviceRequestEventContent {
ToDeviceSecretRequestEventContent {
action: RequestAction::Request(
secret
),
@ -241,7 +241,7 @@ mod test {
assert_matches!(
from_json_value(json).unwrap(),
ToDeviceRequestEventContent {
ToDeviceSecretRequestEventContent {
action: RequestAction::RequestCancellation,
requesting_device_id,
request_id,
@ -262,7 +262,7 @@ mod test {
assert_matches!(
from_json_value(json).unwrap(),
ToDeviceRequestEventContent {
ToDeviceSecretRequestEventContent {
action: RequestAction::Request(
SecretName::RecoveryKey
),
@ -283,8 +283,8 @@ mod test {
});
assert_matches!(
from_json_value::<ToDeviceRequestEventContent>(json).unwrap(),
ToDeviceRequestEventContent {
from_json_value::<ToDeviceSecretRequestEventContent>(json).unwrap(),
ToDeviceSecretRequestEventContent {
action,
requesting_device_id,
request_id,

View File

@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.secret.send", kind = ToDevice)]
pub struct ToDeviceSendEventContent {
pub struct ToDeviceSecretSendEventContent {
/// The ID of the request that this is a response to.
pub request_id: String,
@ -20,7 +20,7 @@ pub struct ToDeviceSendEventContent {
pub secret: String,
}
impl ToDeviceSendEventContent {
impl ToDeviceSecretSendEventContent {
/// Creates a new `SecretSendEventContent` with the given request ID and secret.
pub fn new(request_id: String, secret: String) -> Self {
Self { request_id, secret }

View File

@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.space.child", kind = State)]
pub struct ChildEventContent {
pub struct SpaceChildEventContent {
/// List of candidate servers that can be used to join the room.
#[serde(skip_serializing_if = "Option::is_none")]
pub via: Option<Vec<ServerNameBox>>,
@ -41,7 +41,7 @@ pub struct ChildEventContent {
pub suggested: Option<bool>,
}
impl ChildEventContent {
impl SpaceChildEventContent {
/// Creates a new `ChildEventContent`.
pub fn new() -> Self {
Self::default()
@ -50,13 +50,13 @@ impl ChildEventContent {
#[cfg(test)]
mod tests {
use super::ChildEventContent;
use super::SpaceChildEventContent;
use ruma_identifiers::server_name;
use serde_json::{json, to_value as to_json_value};
#[test]
fn space_child_serialization() {
let content = ChildEventContent {
let content = SpaceChildEventContent {
via: Some(vec![server_name!("example.com")]),
order: Some("uwu".to_owned()),
suggested: Some(false),
@ -73,7 +73,7 @@ mod tests {
#[test]
fn space_child_empty_serialization() {
let content = ChildEventContent { via: None, order: None, suggested: None };
let content = SpaceChildEventContent { via: None, order: None, suggested: None };
let json = json!({});

View File

@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.space.parent", kind = State)]
pub struct ParentEventContent {
pub struct SpaceParentEventContent {
/// List of candidate servers that can be used to join the room.
#[serde(skip_serializing_if = "Option::is_none")]
pub via: Option<Vec<ServerNameBox>>,
@ -29,7 +29,7 @@ pub struct ParentEventContent {
pub canonical: bool,
}
impl ParentEventContent {
impl SpaceParentEventContent {
/// Creates a new `ParentEventContent` with the given canonical flag.
pub fn new(canonical: bool) -> Self {
Self { via: None, canonical }
@ -38,14 +38,16 @@ impl ParentEventContent {
#[cfg(test)]
mod tests {
use super::ParentEventContent;
use super::SpaceParentEventContent;
use ruma_identifiers::server_name;
use serde_json::{json, to_value as to_json_value};
#[test]
fn space_parent_serialization() {
let content =
ParentEventContent { via: Some(vec![server_name!("example.com")]), canonical: true };
let content = SpaceParentEventContent {
via: Some(vec![server_name!("example.com")]),
canonical: true,
};
let json = json!({
"via": ["example.com"],
@ -57,7 +59,7 @@ mod tests {
#[test]
fn space_parent_empty_serialization() {
let content = ParentEventContent { via: None, canonical: true };
let content = SpaceParentEventContent { via: None, canonical: true };
let json = json!({
"canonical": true,

View File

@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "unstable-pre-spec")]
use crate::relation::Relations;
use crate::room::redaction::SyncRedactionEvent;
use crate::room::redaction::SyncRoomRedactionEvent;
/// Extra information about an event that is not incorporated into the event's hash.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
@ -51,7 +51,7 @@ impl Unsigned {
pub struct RedactedUnsigned {
/// The event that redacted this event, if any.
#[serde(skip_serializing_if = "Option::is_none")]
pub redacted_because: Option<Box<SyncRedactionEvent>>,
pub redacted_because: Option<Box<SyncRoomRedactionEvent>>,
}
impl RedactedUnsigned {
@ -61,7 +61,7 @@ impl RedactedUnsigned {
}
/// Create a new `RedactedUnsigned` with the given redacted because.
pub fn new_because(redacted_because: Box<SyncRedactionEvent>) -> Self {
pub fn new_because(redacted_because: Box<SyncRoomRedactionEvent>) -> Self {
Self { redacted_because: Some(redacted_because) }
}
@ -110,7 +110,7 @@ impl From<UnsignedWithPrevContent> for Unsigned {
#[derive(Deserialize)]
pub struct RedactedUnsignedWithPrevContent {
#[serde(skip_serializing_if = "Option::is_none")]
redacted_because: Option<Box<SyncRedactionEvent>>,
redacted_because: Option<Box<SyncRoomRedactionEvent>>,
pub prev_content: Option<Box<serde_json::value::RawValue>>,
}

View File

@ -1,12 +1,12 @@
#![cfg(feature = "compat")]
use matches::assert_matches;
use ruma_events::room::topic::{TopicEvent, TopicEventContent};
use ruma_events::room::topic::{RoomTopicEvent, RoomTopicEventContent};
use serde_json::{from_value as from_json_value, json};
#[test]
fn deserialize_unsigned_prev_content() {
let res = from_json_value::<TopicEvent>(json!({
let res = from_json_value::<RoomTopicEvent>(json!({
"content": {
"topic": "New room topic",
},
@ -26,9 +26,9 @@ fn deserialize_unsigned_prev_content() {
assert_matches!(
res,
Ok(TopicEvent {
content: TopicEventContent { topic: new_topic, .. },
prev_content: Some(TopicEventContent { topic: old_topic, .. }),
Ok(RoomTopicEvent {
content: RoomTopicEventContent { topic: new_topic, .. },
prev_content: Some(RoomTopicEventContent { topic: old_topic, .. }),
..
}) if new_topic == "New room topic"
&& old_topic == "Old room topic"

View File

@ -7,9 +7,9 @@ use serde_json::{from_value as from_json_value, json, Value as JsonValue};
use ruma_events::{
room::{
aliases::AliasesEventContent,
message::{MessageEventContent, MessageType, TextMessageEventContent},
power_levels::PowerLevelsEventContent,
aliases::RoomAliasesEventContent,
message::{MessageType, RoomMessageEventContent, TextMessageEventContent},
power_levels::RoomPowerLevelsEventContent,
},
AnyEphemeralRoomEvent, AnyMessageEvent, AnyRoomEvent, AnyStateEvent, AnyStateEventContent,
AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EphemeralRoomEventType, EventType,
@ -123,7 +123,7 @@ fn power_event_sync_deserialization() {
from_json_value::<AnySyncRoomEvent>(json_data),
Ok(AnySyncRoomEvent::State(
AnySyncStateEvent::RoomPowerLevels(SyncStateEvent {
content: PowerLevelsEventContent {
content: RoomPowerLevelsEventContent {
ban, ..
},
..
@ -141,7 +141,7 @@ fn message_event_sync_deserialization() {
from_json_value::<AnySyncRoomEvent>(json_data),
Ok(AnySyncRoomEvent::Message(
AnySyncMessageEvent::RoomMessage(SyncMessageEvent {
content: MessageEventContent {
content: RoomMessageEventContent {
msgtype: MessageType::Text(TextMessageEventContent {
body,
formatted: Some(formatted),
@ -164,7 +164,7 @@ fn aliases_event_sync_deserialization() {
from_json_value::<AnySyncRoomEvent>(json_data),
Ok(AnySyncRoomEvent::State(
AnySyncStateEvent::RoomAliases(SyncStateEvent {
content: AliasesEventContent {
content: RoomAliasesEventContent {
aliases,
..
},
@ -183,7 +183,7 @@ fn message_room_event_deserialization() {
from_json_value::<AnyRoomEvent>(json_data),
Ok(AnyRoomEvent::Message(
AnyMessageEvent::RoomMessage(MessageEvent {
content: MessageEventContent {
content: RoomMessageEventContent {
msgtype: MessageType::Text(TextMessageEventContent {
body,
formatted: Some(formatted),
@ -201,7 +201,7 @@ fn message_room_event_deserialization() {
#[test]
fn message_event_serialization() {
let event = MessageEvent {
content: MessageEventContent::text_plain("test"),
content: RoomMessageEventContent::text_plain("test"),
event_id: event_id!("$1234:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(0)),
room_id: room_id!("!roomid:example.com"),
@ -223,7 +223,7 @@ fn alias_room_event_deserialization() {
from_json_value::<AnyRoomEvent>(json_data),
Ok(AnyRoomEvent::State(
AnyStateEvent::RoomAliases(StateEvent {
content: AliasesEventContent {
content: RoomAliasesEventContent {
aliases,
..
},
@ -242,7 +242,7 @@ fn message_event_deserialization() {
from_json_value::<AnyRoomEvent>(json_data),
Ok(AnyRoomEvent::Message(
AnyMessageEvent::RoomMessage(MessageEvent {
content: MessageEventContent {
content: RoomMessageEventContent {
msgtype: MessageType::Text(TextMessageEventContent {
body,
formatted: Some(formatted),
@ -265,7 +265,7 @@ fn alias_event_deserialization() {
from_json_value::<AnyRoomEvent>(json_data),
Ok(AnyRoomEvent::State(
AnyStateEvent::RoomAliases(StateEvent {
content: AliasesEventContent {
content: RoomAliasesEventContent {
aliases,
..
},
@ -290,7 +290,8 @@ fn alias_event_field_access() {
);
let deser = from_json_value::<AnyStateEvent>(json_data).unwrap();
if let AnyStateEventContent::RoomAliases(AliasesEventContent { aliases, .. }) = deser.content()
if let AnyStateEventContent::RoomAliases(RoomAliasesEventContent { aliases, .. }) =
deser.content()
{
assert_eq!(aliases, vec![room_alias_id!("#somewhere:localhost")])
} else {

View File

@ -6,7 +6,7 @@ use ruma_identifiers::{event_id, mxc_uri, room_id, user_id};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use ruma_events::{
call::{answer::AnswerEventContent, SessionDescription, SessionDescriptionType},
call::{answer::CallAnswerEventContent, SessionDescription, SessionDescriptionType},
room::{ImageInfo, ThumbnailInfo},
sticker::StickerEventContent,
AnyMessageEvent, MessageEvent, Unsigned,
@ -42,7 +42,7 @@ fn deserialize_message_event() {
from_json_value::<AnyMessageEvent>(json_data)
.unwrap(),
AnyMessageEvent::CallAnswer(MessageEvent {
content: AnswerEventContent {
content: CallAnswerEventContent {
answer: SessionDescription {
session_type: SessionDescriptionType::Answer,
sdp,

View File

@ -3,7 +3,7 @@ use js_int::{uint, UInt};
use matches::assert_matches;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
call::{answer::AnswerEventContent, SessionDescription, SessionDescriptionType},
call::{answer::CallAnswerEventContent, SessionDescription, SessionDescriptionType},
room::{ImageInfo, ThumbnailInfo},
sticker::StickerEventContent,
AnyMessageEvent, AnyMessageEventContent, AnySyncMessageEvent, MessageEvent, RawExt, Unsigned,
@ -84,7 +84,7 @@ fn deserialize_message_call_answer_content() {
.unwrap()
.deserialize_content("m.call.answer")
.unwrap(),
AnyMessageEventContent::CallAnswer(AnswerEventContent {
AnyMessageEventContent::CallAnswer(CallAnswerEventContent {
answer: SessionDescription {
session_type: SessionDescriptionType::Answer,
sdp,
@ -118,7 +118,7 @@ fn deserialize_message_call_answer() {
assert_matches!(
from_json_value::<AnyMessageEvent>(json_data).unwrap(),
AnyMessageEvent::CallAnswer(MessageEvent {
content: AnswerEventContent {
content: CallAnswerEventContent {
answer: SessionDescription {
session_type: SessionDescriptionType::Answer,
sdp,
@ -249,7 +249,7 @@ fn deserialize_message_then_convert_to_full() {
assert_matches!(
from_json_value::<AnyMessageEvent>(full_json).unwrap(),
AnyMessageEvent::CallAnswer(MessageEvent {
content: AnswerEventContent {
content: CallAnswerEventContent {
answer: SessionDescription {
session_type: SessionDescriptionType::Answer,
sdp,

View File

@ -4,10 +4,10 @@ use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
custom::RedactedCustomEventContent,
room::{
aliases::RedactedAliasesEventContent,
create::RedactedCreateEventContent,
message::RedactedMessageEventContent,
redaction::{RedactionEventContent, SyncRedactionEvent},
aliases::RedactedRoomAliasesEventContent,
create::RedactedRoomCreateEventContent,
message::RedactedRoomMessageEventContent,
redaction::{RoomRedactionEventContent, SyncRoomRedactionEvent},
},
AnyMessageEvent, AnyMessageEventContent, AnyRedactedMessageEvent,
AnyRedactedMessageEventContent, AnyRedactedStateEventContent, AnyRedactedSyncMessageEvent,
@ -22,8 +22,8 @@ use serde_json::{
fn unsigned() -> RedactedUnsigned {
let mut unsigned = RedactedUnsigned::default();
unsigned.redacted_because = Some(Box::new(SyncRedactionEvent {
content: RedactionEventContent::with_reason("redacted because".into()),
unsigned.redacted_because = Some(Box::new(SyncRoomRedactionEvent {
content: RoomRedactionEventContent::with_reason("redacted because".into()),
redacts: event_id!("$h29iv0s8:example.com"),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
@ -37,7 +37,7 @@ fn unsigned() -> RedactedUnsigned {
#[test]
fn redacted_message_event_serialize() {
let redacted = RedactedSyncMessageEvent {
content: RedactedMessageEventContent::new(),
content: RedactedRoomMessageEventContent::new(),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
sender: user_id!("@carl:example.com"),
@ -58,7 +58,7 @@ fn redacted_message_event_serialize() {
#[test]
fn redacted_aliases_event_serialize_no_content() {
let redacted = RedactedSyncStateEvent {
content: RedactedAliasesEventContent::default(),
content: RedactedRoomAliasesEventContent::default(),
event_id: event_id!("$h29iv0s8:example.com"),
state_key: "".into(),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
@ -81,7 +81,7 @@ fn redacted_aliases_event_serialize_no_content() {
#[test]
fn redacted_aliases_event_serialize_with_content() {
let redacted = RedactedSyncStateEvent {
content: RedactedAliasesEventContent::new_v1(vec![]),
content: RedactedRoomAliasesEventContent::new_v1(vec![]),
event_id: event_id!("$h29iv0s8:example.com"),
state_key: "".to_owned(),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
@ -121,7 +121,7 @@ fn redacted_aliases_deserialize() {
from_json_value::<AnySyncRoomEvent>(actual).unwrap(),
AnySyncRoomEvent::RedactedState(AnyRedactedSyncStateEvent::RoomAliases(
RedactedSyncStateEvent {
content: RedactedAliasesEventContent { aliases, .. },
content: RedactedRoomAliasesEventContent { aliases, .. },
event_id,
..
},
@ -146,7 +146,7 @@ fn redacted_deserialize_any_room() {
assert_matches!(
from_json_value::<AnyRoomEvent>(actual).unwrap(),
AnyRoomEvent::RedactedMessage(AnyRedactedMessageEvent::RoomMessage(RedactedMessageEvent {
content: RedactedMessageEventContent { .. },
content: RedactedRoomMessageEventContent { .. },
event_id, room_id, ..
})) if event_id == event_id!("$h29iv0s8:example.com")
&& room_id == room_id!("!roomid:room.com")
@ -159,8 +159,8 @@ fn redacted_deserialize_any_room_sync() {
// The presence of `redacted_because` triggers the event enum (AnySyncRoomEvent in this case)
// to return early with `RedactedContent` instead of failing to deserialize according
// to the event type string.
unsigned.redacted_because = Some(Box::new(SyncRedactionEvent {
content: RedactionEventContent::with_reason("redacted because".into()),
unsigned.redacted_because = Some(Box::new(SyncRoomRedactionEvent {
content: RoomRedactionEventContent::with_reason("redacted because".into()),
redacts: event_id!("$h29iv0s8:example.com"),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
@ -182,7 +182,7 @@ fn redacted_deserialize_any_room_sync() {
from_json_value::<AnySyncRoomEvent>(actual).unwrap(),
AnySyncRoomEvent::RedactedMessage(AnyRedactedSyncMessageEvent::RoomMessage(
RedactedSyncMessageEvent {
content: RedactedMessageEventContent { .. },
content: RedactedRoomMessageEventContent { .. },
event_id,
..
}
@ -209,7 +209,7 @@ fn redacted_state_event_deserialize() {
.unwrap(),
AnySyncRoomEvent::RedactedState(AnyRedactedSyncStateEvent::RoomCreate(
RedactedSyncStateEvent {
content: RedactedCreateEventContent {
content: RedactedRoomCreateEventContent {
creator, ..
},
event_id,
@ -285,8 +285,8 @@ fn redact_method_properly_redacts() {
}
});
let redaction = SyncRedactionEvent {
content: RedactionEventContent::with_reason("redacted because".into()),
let redaction = SyncRoomRedactionEvent {
content: RoomRedactionEventContent::with_reason("redacted because".into()),
redacts: event_id!("$143273582443PhrSn:example.com"),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
@ -299,7 +299,7 @@ fn redact_method_properly_redacts() {
assert_matches!(
event.redact(redaction, &RoomVersionId::Version6),
AnyRedactedMessageEvent::RoomMessage(RedactedMessageEvent {
content: RedactedMessageEventContent { .. },
content: RedactedRoomMessageEventContent { .. },
event_id,
room_id,
sender,
@ -326,7 +326,7 @@ fn redact_message_content() {
assert_matches!(
content.redact(&RoomVersionId::Version6),
AnyRedactedMessageEventContent::RoomMessage(RedactedMessageEventContent { .. })
AnyRedactedMessageEventContent::RoomMessage(RedactedRoomMessageEventContent { .. })
);
}
@ -343,7 +343,7 @@ fn redact_state_content() {
assert_matches!(
content.redact(&RoomVersionId::Version6),
AnyRedactedStateEventContent::RoomCreate(RedactedCreateEventContent {
AnyRedactedStateEventContent::RoomCreate(RedactedRoomCreateEventContent {
creator,
..
}) if creator == user_id!("@carl:example.com")

View File

@ -2,7 +2,7 @@ use js_int::uint;
use matches::assert_matches;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
room::redaction::{RedactionEvent, RedactionEventContent},
room::redaction::{RoomRedactionEvent, RoomRedactionEventContent},
AnyMessageEvent, Unsigned,
};
use ruma_identifiers::{event_id, room_id, user_id};
@ -26,8 +26,8 @@ fn redaction() -> JsonValue {
#[test]
fn serialize_redaction() {
let aliases_event = RedactionEvent {
content: RedactionEventContent::with_reason("being a turd".into()),
let aliases_event = RoomRedactionEvent {
content: RoomRedactionEventContent::with_reason("being a turd".into()),
redacts: event_id!("$nomore:example.com"),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
@ -48,8 +48,8 @@ fn deserialize_redaction() {
assert_matches!(
from_json_value::<AnyMessageEvent>(json_data).unwrap(),
AnyMessageEvent::RoomRedaction(RedactionEvent {
content: RedactionEventContent { reason: Some(reas), .. },
AnyMessageEvent::RoomRedaction(RoomRedactionEvent {
content: RoomRedactionEventContent { reason: Some(reas), .. },
redacts,
event_id,
origin_server_ts,

View File

@ -10,8 +10,8 @@ use ruma_events::{
};
use ruma_events::{
room::message::{
AudioMessageEventContent, InReplyTo, MessageEvent, MessageEventContent, MessageType,
Relation, TextMessageEventContent,
AudioMessageEventContent, InReplyTo, MessageType, Relation, RoomMessageEvent,
RoomMessageEventContent, TextMessageEventContent,
},
Unsigned,
};
@ -34,8 +34,8 @@ macro_rules! json_object {
#[test]
fn serialization() {
let ev = MessageEvent {
content: MessageEventContent::new(MessageType::Audio(AudioMessageEventContent::plain(
let ev = RoomMessageEvent {
content: RoomMessageEventContent::new(MessageType::Audio(AudioMessageEventContent::plain(
"test".into(),
mxc_uri!("mxc://example.org/ffed755USFFxlgbQYZGtryd"),
None,
@ -67,7 +67,7 @@ fn serialization() {
#[test]
fn content_serialization() {
let message_event_content =
MessageEventContent::new(MessageType::Audio(AudioMessageEventContent::plain(
RoomMessageEventContent::new(MessageType::Audio(AudioMessageEventContent::plain(
"test".into(),
mxc_uri!("mxc://example.org/ffed755USFFxlgbQYZGtryd"),
None,
@ -127,7 +127,7 @@ fn custom_content_deserialization() {
#[test]
fn formatted_body_serialization() {
let message_event_content =
MessageEventContent::text_html("Hello, World!", "Hello, <em>World</em>!");
RoomMessageEventContent::text_html("Hello, World!", "Hello, <em>World</em>!");
assert_eq!(
to_json_value(&message_event_content).unwrap(),
@ -143,7 +143,7 @@ fn formatted_body_serialization() {
#[test]
fn plain_text_content_serialization() {
let message_event_content =
MessageEventContent::text_plain("> <@test:example.com> test\n\ntest reply");
RoomMessageEventContent::text_plain("> <@test:example.com> test\n\ntest reply");
assert_eq!(
to_json_value(&message_event_content).unwrap(),
@ -157,7 +157,7 @@ fn plain_text_content_serialization() {
#[test]
#[cfg(feature = "markdown")]
fn markdown_content_serialization() {
let formatted_message = MessageEventContent::new(MessageType::Text(
let formatted_message = RoomMessageEventContent::new(MessageType::Text(
TextMessageEventContent::markdown("Testing **bold** and _italic_!"),
));
@ -171,7 +171,7 @@ fn markdown_content_serialization() {
})
);
let plain_message_simple = MessageEventContent::new(MessageType::Text(
let plain_message_simple = RoomMessageEventContent::new(MessageType::Text(
TextMessageEventContent::markdown("Testing a simple phrase…"),
));
@ -183,7 +183,7 @@ fn markdown_content_serialization() {
})
);
let plain_message_paragraphs = MessageEventContent::new(MessageType::Text(
let plain_message_paragraphs = RoomMessageEventContent::new(MessageType::Text(
TextMessageEventContent::markdown("Testing\n\nSeveral\n\nParagraphs."),
));
@ -201,7 +201,7 @@ fn markdown_content_serialization() {
#[test]
fn relates_to_content_serialization() {
let message_event_content =
assign!(MessageEventContent::text_plain("> <@test:example.com> test\n\ntest reply"), {
assign!(RoomMessageEventContent::text_plain("> <@test:example.com> test\n\ntest reply"), {
relates_to: Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$15827405538098VGFWH:example.com")),
}),
@ -236,8 +236,8 @@ fn edit_deserialization_061() {
});
assert_matches!(
from_json_value::<MessageEventContent>(json_data).unwrap(),
MessageEventContent {
from_json_value::<RoomMessageEventContent>(json_data).unwrap(),
RoomMessageEventContent {
msgtype: MessageType::Text(TextMessageEventContent {
body,
formatted: None,
@ -269,8 +269,8 @@ fn edit_deserialization_future() {
});
assert_matches!(
from_json_value::<MessageEventContent>(json_data).unwrap(),
MessageEventContent {
from_json_value::<RoomMessageEventContent>(json_data).unwrap(),
RoomMessageEventContent {
msgtype: MessageType::Text(TextMessageEventContent {
body,
formatted: None,
@ -282,7 +282,7 @@ fn edit_deserialization_future() {
&& event_id == ev_id
&& matches!(
&*new_content,
MessageEventContent {
RoomMessageEventContent {
msgtype: MessageType::Text(TextMessageEventContent {
body,
formatted: None,
@ -313,8 +313,8 @@ fn verification_request_deserialization() {
});
assert_matches!(
from_json_value::<MessageEventContent>(json_data).unwrap(),
MessageEventContent {
from_json_value::<RoomMessageEventContent>(json_data).unwrap(),
RoomMessageEventContent {
msgtype: MessageType::VerificationRequest(KeyVerificationRequestEventContent {
body,
to,
@ -367,9 +367,9 @@ fn content_deserialization() {
});
assert_matches!(
from_json_value::<MessageEventContent>(json_data)
from_json_value::<RoomMessageEventContent>(json_data)
.unwrap(),
MessageEventContent {
RoomMessageEventContent {
msgtype: MessageType::Audio(AudioMessageEventContent {
body,
info: None,
@ -388,5 +388,5 @@ fn content_deserialization_failure() {
"body": "test","msgtype": "m.location",
"url": "http://example.com/audio.mp3"
});
assert!(from_json_value::<MessageEventContent>(json_data).is_err());
assert!(from_json_value::<RoomMessageEventContent>(json_data).is_err());
}

View File

@ -3,8 +3,8 @@ use matches::assert_matches;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
room::{
aliases::AliasesEventContent,
avatar::{AvatarEventContent, ImageInfo},
aliases::RoomAliasesEventContent,
avatar::{ImageInfo, RoomAvatarEventContent},
ThumbnailInfo,
},
AnyRoomEvent, AnyStateEvent, AnyStateEventContent, AnySyncStateEvent, RawExt, StateEvent,
@ -36,10 +36,10 @@ fn aliases_event_with_prev_content() -> JsonValue {
#[test]
fn serialize_aliases_with_prev_content() {
let aliases_event = StateEvent {
content: AliasesEventContent::new(vec![room_alias_id!("#somewhere:localhost")]),
content: RoomAliasesEventContent::new(vec![room_alias_id!("#somewhere:localhost")]),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: Some(AliasesEventContent::new(vec![room_alias_id!("#inner:localhost")])),
prev_content: Some(RoomAliasesEventContent::new(vec![room_alias_id!("#inner:localhost")])),
room_id: room_id!("!roomid:room.com"),
sender: user_id!("@carl:example.com"),
state_key: "".into(),
@ -55,7 +55,7 @@ fn serialize_aliases_with_prev_content() {
#[test]
fn serialize_aliases_without_prev_content() {
let aliases_event = StateEvent {
content: AliasesEventContent::new(vec![room_alias_id!("#somewhere:localhost")]),
content: RoomAliasesEventContent::new(vec![room_alias_id!("#somewhere:localhost")]),
event_id: event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
prev_content: None,
@ -184,7 +184,7 @@ fn deserialize_avatar_without_prev_content() {
assert_matches!(
from_json_value::<AnyStateEvent>(json_data).unwrap(),
AnyStateEvent::RoomAvatar(StateEvent {
content: AvatarEventContent {
content: RoomAvatarEventContent {
info: Some(info),
url,
..

View File

@ -2,7 +2,7 @@ use std::convert::TryFrom;
use js_int::uint;
use ruma_events::{
room::{join_rules::JoinRule, topic::TopicEventContent},
room::{join_rules::JoinRule, topic::RoomTopicEventContent},
AnyStrippedStateEvent, StrippedStateEvent,
};
use ruma_identifiers::{mxc_uri, user_id, RoomNameBox};
@ -11,7 +11,7 @@ use serde_json::{from_value as from_json_value, json, to_value as to_json_value}
#[test]
fn serialize_stripped_state_event_any_content() {
let event = StrippedStateEvent {
content: TopicEventContent::new("Testing room".into()),
content: RoomTopicEventContent::new("Testing room".into()),
state_key: "".into(),
sender: user_id!("@example:localhost"),
};
@ -31,7 +31,7 @@ fn serialize_stripped_state_event_any_content() {
#[test]
fn serialize_stripped_state_event_any_event() {
let event = AnyStrippedStateEvent::RoomTopic(StrippedStateEvent {
content: TopicEventContent::new("Testing room".into()),
content: RoomTopicEventContent::new("Testing room".into()),
state_key: "".into(),
sender: user_id!("@example:localhost"),
});

View File

@ -1,7 +1,7 @@
//! [PUT /_matrix/federation/v1/send_knock/{roomId}/{eventId}](https://spec.matrix.org/unstable/server-server-api/#put_matrixfederationv1send_knockroomideventid)
use ruma_api::ruma_api;
use ruma_events::{room::member::MemberEvent, AnyStrippedStateEvent};
use ruma_events::{room::member::RoomMemberEvent, AnyStrippedStateEvent};
use ruma_identifiers::{EventId, RoomId};
ruma_api! {
@ -25,7 +25,7 @@ ruma_api! {
/// The full knock event.
#[ruma_api(body)]
pub knock_event: &'a MemberEvent,
pub knock_event: &'a RoomMemberEvent,
}
response: {
@ -36,7 +36,11 @@ ruma_api! {
impl<'a> Request<'a> {
/// Creates a new `Request` with the given room ID, event ID and knock event.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, knock_event: &'a MemberEvent) -> Self {
pub fn new(
room_id: &'a RoomId,
event_id: &'a EventId,
knock_event: &'a RoomMemberEvent,
) -> Self {
Self { room_id, event_id, knock_event }
}
}

View File

@ -2,7 +2,7 @@
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{room::member::MemberEventContent, AnyStrippedStateEvent, EventType};
use ruma_events::{room::member::RoomMemberEventContent, AnyStrippedStateEvent, EventType};
use ruma_identifiers::{EventId, RoomId, ServerName, UserId};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
@ -44,7 +44,7 @@ ruma_api! {
pub state_key: &'a UserId,
/// The content of the event.
pub content: MemberEventContent,
pub content: RoomMemberEventContent,
/// Information included alongside the event that is not signed.
#[serde(default, skip_serializing_if = "UnsignedEventContent::is_empty")]
@ -105,7 +105,7 @@ pub struct RequestInit<'a> {
pub state_key: &'a UserId,
/// The content of the event.
pub content: MemberEventContent,
pub content: RoomMemberEventContent,
/// Information included alongside the event that is not signed.
pub unsigned: UnsignedEventContent,

View File

@ -3,7 +3,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{room::member::MemberEventContent, EventType};
use ruma_events::{room::member::RoomMemberEventContent, EventType};
use ruma_identifiers::{EventId, RoomId, ServerName, UserId};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
@ -50,7 +50,7 @@ ruma_api! {
/// The content of the event.
#[ruma_api(query)]
pub content: Raw<MemberEventContent>,
pub content: Raw<RoomMemberEventContent>,
/// This field must be present but is ignored; it may be 0.
#[ruma_api(query)]
@ -97,7 +97,7 @@ pub struct RequestInit<'a> {
pub state_key: &'a str,
/// The content of the event.
pub content: Raw<MemberEventContent>,
pub content: Raw<RoomMemberEventContent>,
/// This field must be present but is ignored; it may be 0.
pub depth: UInt,

View File

@ -24,8 +24,8 @@ use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
pdu::{EventHash, Pdu, RoomV3Pdu},
room::{
join_rules::{JoinRule, JoinRulesEventContent},
member::{MemberEventContent, MembershipState},
join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent},
},
EventType,
};
@ -264,7 +264,7 @@ impl TestStore<StateEvent> {
alice(),
EventType::RoomJoinRules,
Some(""),
to_raw_json_value(&JoinRulesEventContent::new(JoinRule::Public)).unwrap(),
to_raw_json_value(&RoomJoinRulesEventContent::new(JoinRule::Public)).unwrap(),
&[cre.clone(), alice_mem.event_id().clone()],
&[alice_mem.event_id().clone()],
);
@ -356,11 +356,11 @@ fn room_id() -> RoomId {
}
fn member_content_ban() -> Box<RawJsonValue> {
to_raw_json_value(&MemberEventContent::new(MembershipState::Ban)).unwrap()
to_raw_json_value(&RoomMemberEventContent::new(MembershipState::Ban)).unwrap()
}
fn member_content_join() -> Box<RawJsonValue> {
to_raw_json_value(&MemberEventContent::new(MembershipState::Join)).unwrap()
to_raw_json_value(&RoomMemberEventContent::new(MembershipState::Join)).unwrap()
}
fn to_pdu_event<S>(
@ -441,7 +441,7 @@ fn INITIAL_EVENTS() -> HashMap<EventId, Arc<StateEvent>> {
alice(),
EventType::RoomJoinRules,
Some(""),
to_raw_json_value(&JoinRulesEventContent::new(JoinRule::Public)).unwrap(),
to_raw_json_value(&RoomJoinRulesEventContent::new(JoinRule::Public)).unwrap(),
&["CREATE", "IMA", "IPOWER"],
&["IPOWER"],
),

View File

@ -3,11 +3,11 @@ use std::{collections::BTreeSet, convert::TryFrom};
use js_int::{int, Int};
use ruma_events::{
room::{
create::CreateEventContent,
join_rules::{JoinRule, JoinRulesEventContent},
create::RoomCreateEventContent,
join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, ThirdPartyInvite},
power_levels::PowerLevelsEventContent,
third_party_invite::ThirdPartyInviteEventContent,
power_levels::RoomPowerLevelsEventContent,
third_party_invite::RoomThirdPartyInviteEventContent,
},
EventType,
};
@ -281,7 +281,7 @@ pub fn auth_check<E: Event>(
} else {
// If no power level event found the creator gets 100 everyone else gets 0
room_create_event
.and_then(|create| from_json_str::<CreateEventContent>(create.content().get()).ok())
.and_then(|create| from_json_str::<RoomCreateEventContent>(create.content().get()).ok())
.and_then(|create| (create.creator == *sender).then(|| int!(100)))
.unwrap_or_default()
};
@ -414,9 +414,9 @@ fn valid_membership_change(
None => MembershipState::Leave,
};
let power_levels: PowerLevelsEventContent = match &power_levels_event {
let power_levels: RoomPowerLevelsEventContent = match &power_levels_event {
Some(ev) => from_json_str(ev.content().get())?,
None => PowerLevelsEventContent::default(),
None => RoomPowerLevelsEventContent::default(),
};
let sender_power = power_levels
@ -430,7 +430,7 @@ fn valid_membership_change(
let mut join_rules = JoinRule::Invite;
if let Some(jr) = &join_rules_event {
join_rules = from_json_str::<JoinRulesEventContent>(jr.content().get())?.join_rule;
join_rules = from_json_str::<RoomJoinRulesEventContent>(jr.content().get())?.join_rule;
}
if let Some(prev) = prev_event {
@ -613,10 +613,10 @@ fn check_power_levels(
// If users key in content is not a dictionary with keys that are valid user IDs
// with values that are integers (or a string that is an integer), reject.
let user_content =
from_json_str::<PowerLevelsEventContent>(power_event.content().get()).unwrap();
from_json_str::<RoomPowerLevelsEventContent>(power_event.content().get()).unwrap();
let current_content =
from_json_str::<PowerLevelsEventContent>(current_state.content().get()).unwrap();
from_json_str::<RoomPowerLevelsEventContent>(current_state.content().get()).unwrap();
// Validation of users is done in Ruma, synapse for loops validating user_ids and integers here
info!("validation of power event finished");
@ -768,7 +768,7 @@ fn get_send_level(
) -> Int {
power_lvl
.and_then(|ple| {
from_json_str::<PowerLevelsEventContent>(ple.content().get())
from_json_str::<RoomPowerLevelsEventContent>(ple.content().get())
.map(|content| {
content.events.get(e_type).copied().unwrap_or_else(|| {
if state_key.is_some() {
@ -811,7 +811,7 @@ fn verify_third_party_invite(
// If any signature in signed matches any public key in the m.room.third_party_invite event,
// allow
if let Ok(tpid_ev) =
from_json_str::<ThirdPartyInviteEventContent>(current_tpid.content().get())
from_json_str::<RoomThirdPartyInviteEventContent>(current_tpid.content().get())
{
// A list of public keys in the public_keys field
for key in tpid_ev.public_keys.unwrap_or_default() {

View File

@ -7,7 +7,7 @@ use itertools::Itertools;
use js_int::{int, Int};
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
room::member::{MemberEventContent, MembershipState},
room::member::{MembershipState, RoomMemberEventContent},
EventType,
};
use ruma_identifiers::{EventId, RoomVersionId, UserId};
@ -601,7 +601,7 @@ fn is_power_event(event: impl Event) -> bool {
event.state_key() == Some("")
}
EventType::RoomMember => {
if let Ok(content) = from_json_str::<MemberEventContent>(event.content().get()) {
if let Ok(content) = from_json_str::<RoomMemberEventContent>(event.content().get()) {
if [MembershipState::Leave, MembershipState::Ban].contains(&content.membership) {
return Some(event.sender().as_str()) != event.state_key();
}
@ -625,7 +625,7 @@ mod tests {
use rand::seq::SliceRandom;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
room::join_rules::{JoinRule, JoinRulesEventContent},
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
EventType,
};
use ruma_identifiers::{EventId, RoomVersionId};
@ -877,7 +877,7 @@ mod tests {
alice(),
EventType::RoomJoinRules,
Some(""),
to_raw_json_value(&JoinRulesEventContent::new(JoinRule::Private)).unwrap(),
to_raw_json_value(&RoomJoinRulesEventContent::new(JoinRule::Private)).unwrap(),
),
to_init_pdu_event(
"ME",

View File

@ -12,8 +12,8 @@ use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{
pdu::{EventHash, Pdu, RoomV3Pdu},
room::{
join_rules::{JoinRule, JoinRulesEventContent},
member::{MemberEventContent, MembershipState},
join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent},
},
EventType,
};
@ -269,7 +269,7 @@ impl TestStore<StateEvent> {
alice(),
EventType::RoomJoinRules,
Some(""),
to_raw_json_value(&JoinRulesEventContent::new(JoinRule::Public)).unwrap(),
to_raw_json_value(&RoomJoinRulesEventContent::new(JoinRule::Public)).unwrap(),
&[cre.clone(), alice_mem.event_id().clone()],
&[alice_mem.event_id().clone()],
);
@ -365,11 +365,11 @@ pub fn room_id() -> RoomId {
}
pub fn member_content_ban() -> Box<RawJsonValue> {
to_raw_json_value(&MemberEventContent::new(MembershipState::Ban)).unwrap()
to_raw_json_value(&RoomMemberEventContent::new(MembershipState::Ban)).unwrap()
}
pub fn member_content_join() -> Box<RawJsonValue> {
to_raw_json_value(&MemberEventContent::new(MembershipState::Join)).unwrap()
to_raw_json_value(&RoomMemberEventContent::new(MembershipState::Join)).unwrap()
}
pub fn to_init_pdu_event(
@ -481,7 +481,7 @@ pub fn INITIAL_EVENTS() -> HashMap<EventId, Arc<StateEvent>> {
alice(),
EventType::RoomJoinRules,
Some(""),
to_raw_json_value(&JoinRulesEventContent::new(JoinRule::Public)).unwrap(),
to_raw_json_value(&RoomJoinRulesEventContent::new(JoinRule::Public)).unwrap(),
&["CREATE", "IMA", "IPOWER"],
&["IPOWER"],
),

View File

@ -5,7 +5,7 @@ use std::{convert::TryFrom, env, process::exit};
use ruma::{
api::client::r0::{alias::get_alias, membership::join_room_by_id, message::send_message_event},
events::room::message::MessageEventContent,
events::room::message::RoomMessageEventContent,
RoomAliasId,
};
@ -27,7 +27,7 @@ async fn hello_world(
.send_request(send_message_event::Request::new(
&room_id,
"1",
&MessageEventContent::text_plain("Hello World!"),
&RoomMessageEventContent::text_plain("Hello World!"),
)?)
.await?;

View File

@ -2,7 +2,7 @@ use std::{convert::TryFrom, env, process::exit};
use ruma::{
api::client::r0::{alias::get_alias, membership::join_room_by_id, message::send_message_event},
events::room::message::MessageEventContent,
events::room::message::RoomMessageEventContent,
RoomAliasId,
};
@ -23,7 +23,7 @@ async fn hello_world(
.send_request(send_message_event::Request::new(
&room_id,
"1",
&MessageEventContent::text_plain("Hello World!"),
&RoomMessageEventContent::text_plain("Hello World!"),
)?)
.await?;

View File

@ -4,7 +4,7 @@ use assign::assign;
use ruma::{
api::client::r0::{filter::FilterDefinition, sync::sync_events},
events::{
room::message::{MessageEventContent, MessageType, TextMessageEventContent},
room::message::{MessageType, RoomMessageEventContent, TextMessageEventContent},
AnySyncMessageEvent, AnySyncRoomEvent, SyncMessageEvent,
},
presence::PresenceState,
@ -44,7 +44,7 @@ async fn log_messages(
if let AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomMessage(
SyncMessageEvent {
content:
MessageEventContent {
RoomMessageEventContent {
msgtype:
MessageType::Text(TextMessageEventContent {
body: msg_body, ..