Declare more state event content structs without ruma_event!

This commit is contained in:
Jonas Platte 2020-05-24 00:03:39 +02:00
parent eceef3b96d
commit 1377487b6c
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
5 changed files with 88 additions and 107 deletions

View File

@ -1,16 +1,15 @@
//! Types for the *m.room.encryption* event. //! Types for the *m.room.encryption* event.
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::ruma_event; use ruma_events_macros::{FromRaw, StateEventContent};
use serde::Serialize;
use crate::Algorithm; use crate::Algorithm;
ruma_event! {
/// Defines how messages sent in this room should be encrypted. /// Defines how messages sent in this room should be encrypted.
EncryptionEvent { #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
kind: StateEvent, #[ruma_event(type = "m.room.encryption")]
event_type: "m.room.encryption", pub struct EncryptionEventContent {
content: {
/// The encryption algorithm to be used to encrypt messages sent in this room. /// The encryption algorithm to be used to encrypt messages sent in this room.
/// ///
/// Must be `m.megolm.v1.aes-sha2`. /// Must be `m.megolm.v1.aes-sha2`.
@ -25,6 +24,4 @@ ruma_event! {
/// ///
/// 100 is the recommended default. /// 100 is the recommended default.
pub rotation_period_msgs: Option<UInt>, pub rotation_period_msgs: Option<UInt>,
},
}
} }

View File

@ -1,22 +1,18 @@
//! Types for the *m.room.guest_access* event. //! Types for the *m.room.guest_access* event.
use ruma_events_macros::ruma_event; use ruma_events_macros::{FromRaw, StateEventContent};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, EnumString}; use strum::{Display, EnumString};
ruma_event! {
/// Controls whether guest users are allowed to join rooms. /// Controls whether guest users are allowed to join rooms.
/// ///
/// This event controls whether guest users are allowed to join rooms. If this event is absent, /// This event controls whether guest users are allowed to join rooms. If this event is absent,
/// servers should act as if it is present and has the value `GuestAccess::Forbidden`. /// servers should act as if it is present and has the value `GuestAccess::Forbidden`.
GuestAccessEvent { #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
kind: StateEvent, #[ruma_event(type = "m.room.guest_access")]
event_type: "m.room.guest_access", pub struct GuestAccessEventContent {
content: {
/// A policy for guest user access to a room. /// A policy for guest user access to a room.
pub guest_access: GuestAccess, pub guest_access: GuestAccess,
},
}
} }
/// A policy for guest user access to a room. /// A policy for guest user access to a room.

View File

@ -1,20 +1,16 @@
//! Types for the *m.room.history_visibility* event. //! Types for the *m.room.history_visibility* event.
use ruma_events_macros::ruma_event; use ruma_events_macros::{FromRaw, StateEventContent};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, EnumString}; use strum::{Display, EnumString};
ruma_event! {
/// This event controls whether a member of a room can see the events that happened in a room /// This event controls whether a member of a room can see the events that happened in a room
/// from before they joined. /// from before they joined.
HistoryVisibilityEvent { #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
kind: StateEvent, #[ruma_event(type = "m.room.history_visibility")]
event_type: "m.room.history_visibility", pub struct HistoryVisibilityEventContent {
content: {
/// Who can see the room history. /// Who can see the room history.
pub history_visibility: HistoryVisibility, pub history_visibility: HistoryVisibility,
},
}
} }
/// Who can see a room's history. /// Who can see a room's history.

View File

@ -1,19 +1,15 @@
//! Types for the *m.room.join_rules* event. //! Types for the *m.room.join_rules* event.
use ruma_events_macros::ruma_event; use ruma_events_macros::{FromRaw, StateEventContent};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, EnumString}; use strum::{Display, EnumString};
ruma_event! {
/// Describes how users are allowed to join the room. /// Describes how users are allowed to join the room.
JoinRulesEvent { #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
kind: StateEvent, #[ruma_event(type = "m.room.join_rules")]
event_type: "m.room.join_rules", pub struct JoinRulesEventContent {
content: {
/// The type of rules used for users wishing to join this room. /// The type of rules used for users wishing to join this room.
pub join_rule: JoinRule, pub join_rule: JoinRule,
},
}
} }
/// The rule used for users wishing to join this room. /// The rule used for users wishing to join this room.

View File

@ -2,12 +2,11 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::ruma_event; use ruma_events_macros::{FromRaw, StateEventContent};
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, EnumString}; use strum::{Display, EnumString};
ruma_event! {
/// The current membership state of a user in the room. /// The current membership state of a user in the room.
/// ///
/// Adjusts the membership state for a user in a room. It is preferable to use the membership /// Adjusts the membership state for a user in a room. It is preferable to use the membership
@ -33,10 +32,9 @@ ruma_event! {
/// The membership for a given user can change over time. Previous membership can be retrieved /// The membership for a given user can change over time. Previous membership can be retrieved
/// from the `prev_content` object on an event. If not present, the user's previous membership /// from the `prev_content` object on an event. If not present, the user's previous membership
/// must be assumed as leave. /// must be assumed as leave.
MemberEvent { #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
kind: StateEvent, #[ruma_event(type = "m.room.member")]
event_type: "m.room.member", pub struct MemberEventContent {
content: {
/// The avatar URL for this user, if any. This is added by the homeserver. /// The avatar URL for this user, if any. This is added by the homeserver.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>, pub avatar_url: Option<String>,
@ -57,8 +55,6 @@ ruma_event! {
/// contain information about that invitation. /// contain information about that invitation.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub third_party_invite: Option<ThirdPartyInvite>, pub third_party_invite: Option<ThirdPartyInvite>,
},
}
} }
/// The membership state of a user. /// The membership state of a user.