Convert remaining state structs from ruma_event! to derive(StateEventContent)
This commit is contained in:
parent
74f680f8ed
commit
b95b7db0d4
@ -1,27 +1,23 @@
|
|||||||
//! Types for the *m.room.message.feedback* event.
|
//! Types for the *m.room.message.feedback* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::{FromRaw, MessageEventContent};
|
||||||
use ruma_identifiers::EventId;
|
use ruma_identifiers::EventId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
use strum::{Display, EnumString};
|
||||||
|
|
||||||
ruma_event! {
|
/// An acknowledgement of a message.
|
||||||
/// An acknowledgement of a message.
|
///
|
||||||
///
|
/// N.B.: Usage of this event is discouraged in favor of the receipts module. Most clients will
|
||||||
/// N.B.: Usage of this event is discouraged in favor of the receipts module. Most clients will
|
/// not recognize this event.
|
||||||
/// not recognize this event.
|
#[derive(Clone, Debug, Serialize, FromRaw, MessageEventContent)]
|
||||||
FeedbackEvent {
|
#[ruma_event(type = "m.room.message.feedback")]
|
||||||
kind: RoomEvent,
|
pub struct FeedbackEventContent {
|
||||||
event_type: "m.room.message.feedback",
|
/// The event that this feedback is related to.
|
||||||
content: {
|
pub target_event_id: EventId,
|
||||||
/// The event that this feedback is related to.
|
|
||||||
pub target_event_id: EventId,
|
|
||||||
|
|
||||||
/// The type of feedback.
|
/// The type of feedback.
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub feedback_type: FeedbackType,
|
pub feedback_type: FeedbackType,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type of feedback.
|
/// A type of feedback.
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
//! Types for the *m.room.pinned_events* event.
|
//! Types for the *m.room.pinned_events* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::{FromRaw, StateEventContent};
|
||||||
use ruma_identifiers::EventId;
|
use ruma_identifiers::EventId;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
ruma_event! {
|
/// Used to "pin" particular events in a room for other participants to review later.
|
||||||
/// Used to "pin" particular events in a room for other participants to review later.
|
#[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
|
||||||
PinnedEventsEvent {
|
#[ruma_event(type = "m.room.pinned_events")]
|
||||||
kind: StateEvent,
|
pub struct PinnedEventsEventContent {
|
||||||
event_type: "m.room.pinned_events",
|
/// An ordered list of event IDs to pin.
|
||||||
content: {
|
pub pinned: Vec<EventId>,
|
||||||
/// An ordered list of event IDs to pin.
|
|
||||||
pub pinned: Vec<EventId>,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -3,80 +3,76 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use js_int::Int;
|
use js_int::Int;
|
||||||
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 crate::EventType;
|
use crate::EventType;
|
||||||
|
|
||||||
ruma_event! {
|
/// Defines the power levels (privileges) of users in the room.
|
||||||
/// Defines the power levels (privileges) of users in the room.
|
#[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
|
||||||
PowerLevelsEvent {
|
#[ruma_event(type = "m.room.power_levels")]
|
||||||
kind: StateEvent,
|
pub struct PowerLevelsEventContent {
|
||||||
event_type: "m.room.power_levels",
|
/// The level required to ban a user.
|
||||||
content: {
|
#[serde(
|
||||||
/// The level required to ban a user.
|
default = "default_power_level",
|
||||||
#[serde(
|
skip_serializing_if = "is_default_power_level"
|
||||||
default = "default_power_level",
|
)]
|
||||||
skip_serializing_if = "is_default_power_level"
|
pub ban: Int,
|
||||||
)]
|
|
||||||
pub ban: Int,
|
|
||||||
|
|
||||||
/// The level required to send specific event types.
|
/// The level required to send specific event types.
|
||||||
///
|
///
|
||||||
/// This is a mapping from event type to power level required.
|
/// This is a mapping from event type to power level required.
|
||||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub events: BTreeMap<EventType, Int>,
|
pub events: BTreeMap<EventType, Int>,
|
||||||
|
|
||||||
/// The default level required to send message events.
|
/// The default level required to send message events.
|
||||||
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
||||||
pub events_default: Int,
|
pub events_default: Int,
|
||||||
|
|
||||||
/// The level required to invite a user.
|
/// The level required to invite a user.
|
||||||
#[serde(
|
#[serde(
|
||||||
default = "default_power_level",
|
default = "default_power_level",
|
||||||
skip_serializing_if = "is_default_power_level"
|
skip_serializing_if = "is_default_power_level"
|
||||||
)]
|
)]
|
||||||
pub invite: Int,
|
pub invite: Int,
|
||||||
|
|
||||||
/// The level required to kick a user.
|
/// The level required to kick a user.
|
||||||
#[serde(
|
#[serde(
|
||||||
default = "default_power_level",
|
default = "default_power_level",
|
||||||
skip_serializing_if = "is_default_power_level"
|
skip_serializing_if = "is_default_power_level"
|
||||||
)]
|
)]
|
||||||
pub kick: Int,
|
pub kick: Int,
|
||||||
|
|
||||||
/// The level required to redact an event.
|
/// The level required to redact an event.
|
||||||
#[serde(
|
#[serde(
|
||||||
default = "default_power_level",
|
default = "default_power_level",
|
||||||
skip_serializing_if = "is_default_power_level"
|
skip_serializing_if = "is_default_power_level"
|
||||||
)]
|
)]
|
||||||
pub redact: Int,
|
pub redact: Int,
|
||||||
|
|
||||||
/// The default level required to send state events.
|
/// The default level required to send state events.
|
||||||
#[serde(
|
#[serde(
|
||||||
default = "default_power_level",
|
default = "default_power_level",
|
||||||
skip_serializing_if = "is_default_power_level"
|
skip_serializing_if = "is_default_power_level"
|
||||||
)]
|
)]
|
||||||
pub state_default: Int,
|
pub state_default: Int,
|
||||||
|
|
||||||
/// The power levels for specific users.
|
/// The power levels for specific users.
|
||||||
///
|
///
|
||||||
/// This is a mapping from `user_id` to power level for that user.
|
/// This is a mapping from `user_id` to power level for that user.
|
||||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub users: BTreeMap<UserId, Int>,
|
pub users: BTreeMap<UserId, Int>,
|
||||||
|
|
||||||
/// The default power level for every user in the room.
|
/// The default power level for every user in the room.
|
||||||
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
||||||
pub users_default: Int,
|
pub users_default: Int,
|
||||||
|
|
||||||
/// The power level requirements for specific notification types.
|
/// The power level requirements for specific notification types.
|
||||||
///
|
///
|
||||||
/// This is a mapping from `key` to power level for that notifications key.
|
/// This is a mapping from `key` to power level for that notifications key.
|
||||||
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
||||||
pub notifications: NotificationPowerLevels,
|
pub notifications: NotificationPowerLevels,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PowerLevelsEventContent {
|
impl Default for PowerLevelsEventContent {
|
||||||
|
@ -1,42 +1,39 @@
|
|||||||
//! Types for the *m.room.server_acl* event.
|
//! Types for the *m.room.server_acl* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::{FromRaw, StateEventContent};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
ruma_event! {
|
/// An event to indicate which servers are permitted to participate in the room.
|
||||||
/// An event to indicate which servers are permitted to participate in the room.
|
#[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
|
||||||
ServerAclEvent {
|
#[ruma_event(type = "m.room.server_acl")]
|
||||||
kind: StateEvent,
|
pub struct ServerAclEventContent {
|
||||||
event_type: "m.room.server_acl",
|
/// True to allow server names that are IP address literals. False to deny.
|
||||||
content: {
|
///
|
||||||
/// True to allow server names that are IP address literals. False to deny.
|
/// This is strongly recommended to be set to false as servers running with IP literal
|
||||||
///
|
/// names are strongly discouraged in order to require legitimate homeservers to be
|
||||||
/// This is strongly recommended to be set to false as servers running with IP literal
|
/// backed by a valid registered domain name.
|
||||||
/// names are strongly discouraged in order to require legitimate homeservers to be
|
#[serde(
|
||||||
/// backed by a valid registered domain name.
|
default = "ruma_serde::default_true",
|
||||||
#[serde(
|
skip_serializing_if = "ruma_serde::is_true"
|
||||||
default = "ruma_serde::default_true",
|
)]
|
||||||
skip_serializing_if = "ruma_serde::is_true"
|
pub allow_ip_literals: bool,
|
||||||
)]
|
|
||||||
pub allow_ip_literals: bool,
|
|
||||||
|
|
||||||
/// The server names to allow in the room, excluding any port information. Wildcards may
|
/// The server names to allow in the room, excluding any port information. Wildcards may
|
||||||
/// be used to cover a wider range of hosts, where `*` matches zero or more characters
|
/// be used to cover a wider range of hosts, where `*` matches zero or more characters
|
||||||
/// and `?` matches exactly one character.
|
/// and `?` matches exactly one character.
|
||||||
///
|
///
|
||||||
/// **This defaults to an empty list when not provided, effectively disallowing every
|
/// **This defaults to an empty list when not provided, effectively disallowing every
|
||||||
/// server.**
|
/// server.**
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub allow: Vec<String>,
|
pub allow: Vec<String>,
|
||||||
|
|
||||||
/// The server names to disallow in the room, excluding any port information. Wildcards may
|
/// The server names to disallow in the room, excluding any port information. Wildcards may
|
||||||
/// be used to cover a wider range of hosts, where * matches zero or more characters and ?
|
/// be used to cover a wider range of hosts, where * matches zero or more characters and ?
|
||||||
/// matches exactly one character.
|
/// matches exactly one character.
|
||||||
///
|
///
|
||||||
/// This defaults to an empty list when not provided.
|
/// This defaults to an empty list when not provided.
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub deny: Vec<String>,
|
pub deny: Vec<String>,
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,32 +1,28 @@
|
|||||||
//! Types for the *m.room.third_party_invite* event.
|
//! Types for the *m.room.third_party_invite* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::{FromRaw, StateEventContent};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
/// An invitation to a room issued to a third party identifier, rather than a matrix user ID.
|
||||||
/// An invitation to a room issued to a third party identifier, rather than a matrix user ID.
|
///
|
||||||
///
|
/// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This
|
||||||
/// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This
|
/// event contains a token and a public key whose private key must be used to sign the token.
|
||||||
/// event contains a token and a public key whose private key must be used to sign the token.
|
/// Any user who can present that signature may use this invitation to join the target room.
|
||||||
/// Any user who can present that signature may use this invitation to join the target room.
|
#[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
|
||||||
ThirdPartyInviteEvent {
|
#[ruma_event(type = "m.room.third_party_invite")]
|
||||||
kind: StateEvent,
|
pub struct ThirdPartyInviteEventContent {
|
||||||
event_type: "m.room.third_party_invite",
|
/// A user-readable string which represents the user who has been invited.
|
||||||
content: {
|
pub display_name: String,
|
||||||
/// A user-readable string which represents the user who has been invited.
|
|
||||||
pub display_name: String,
|
|
||||||
|
|
||||||
/// A URL which can be fetched to validate whether the key has been revoked.
|
/// A URL which can be fetched to validate whether the key has been revoked.
|
||||||
pub key_validity_url: String,
|
pub key_validity_url: String,
|
||||||
|
|
||||||
/// A Base64-encoded Ed25519 key with which the token must be signed.
|
/// A Base64-encoded Ed25519 key with which the token must be signed.
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
|
|
||||||
/// Keys with which the token may be signed.
|
/// Keys with which the token may be signed.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub public_keys: Option<Vec<PublicKey>>,
|
pub public_keys: Option<Vec<PublicKey>>,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A public key for signing a third party invite token.
|
/// A public key for signing a third party invite token.
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
//! Types for the *m.room.tombstone* event.
|
//! Types for the *m.room.tombstone* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::{FromRaw, StateEventContent};
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
ruma_event! {
|
/// A state event signifying that a room has been upgraded to a different room version, and that
|
||||||
/// A state event signifying that a room has been upgraded to a different room version, and that
|
/// clients should go there.
|
||||||
/// clients should go there.
|
#[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
|
||||||
TombstoneEvent {
|
#[ruma_event(type = "m.room.tombstone")]
|
||||||
kind: StateEvent,
|
pub struct TombstoneEventContent {
|
||||||
event_type: "m.room.tombstone",
|
/// A server-defined message.
|
||||||
content: {
|
pub body: String,
|
||||||
/// A server-defined message.
|
|
||||||
pub body: String,
|
|
||||||
|
|
||||||
/// The new room the client should be visiting.
|
/// The new room the client should be visiting.
|
||||||
pub replacement_room: RoomId,
|
pub replacement_room: RoomId,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
//! Types for the *m.room.topic* event.
|
//! Types for the *m.room.topic* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::{FromRaw, StateEventContent};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
ruma_event! {
|
/// A topic is a short message detailing what is currently being discussed in the room.
|
||||||
/// A topic is a short message detailing what is currently being discussed in the room.
|
#[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)]
|
||||||
TopicEvent {
|
#[ruma_event(type = "m.room.topic")]
|
||||||
kind: StateEvent,
|
pub struct TopicEventContent {
|
||||||
event_type: "m.room.topic",
|
/// The topic text.
|
||||||
content: {
|
pub topic: String,
|
||||||
/// The topic text.
|
|
||||||
pub topic: String,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user