Update matrix events to their latest version
This commit is contained in:
parent
a51448e09d
commit
a9490dbee8
@ -10,7 +10,7 @@ room_event! {
|
|||||||
/// The payload of an `AnswerEvent`.
|
/// The payload of an `AnswerEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct AnswerEventContent {
|
pub struct AnswerEventContent {
|
||||||
/// The VoIP session description.
|
/// The VoIP session description object. The session description type must be *answer*.
|
||||||
pub answer: SessionDescription,
|
pub answer: SessionDescription,
|
||||||
/// The ID of the call this event relates to.
|
/// The ID of the call this event relates to.
|
||||||
pub call_id: String,
|
pub call_id: String,
|
||||||
|
@ -16,7 +16,7 @@ pub struct InviteEventContent {
|
|||||||
/// value, clients should discard it. They should also no longer show the call as awaiting an
|
/// value, clients should discard it. They should also no longer show the call as awaiting an
|
||||||
/// answer in the UI.
|
/// answer in the UI.
|
||||||
pub lifetime: u64,
|
pub lifetime: u64,
|
||||||
/// The session description object.
|
/// The session description object. The session description type must be *offer*.
|
||||||
pub offer: SessionDescription,
|
pub offer: SessionDescription,
|
||||||
/// The version of the VoIP specification this messages adheres to.
|
/// The version of the VoIP specification this messages adheres to.
|
||||||
pub version: u64,
|
pub version: u64,
|
||||||
|
15
src/lib.rs
15
src/lib.rs
@ -192,12 +192,6 @@ pub trait Event where Self: Debug + for<'a> Deserialize<'a> + Serialize {
|
|||||||
|
|
||||||
/// The type of the event.
|
/// The type of the event.
|
||||||
fn event_type(&self) -> &EventType;
|
fn event_type(&self) -> &EventType;
|
||||||
|
|
||||||
/// Extra top-level key-value pairs specific to this event type, but that are not under the
|
|
||||||
/// `content` field.
|
|
||||||
fn extra_content(&self) -> Option<Value> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event within the context of a room.
|
/// An event within the context of a room.
|
||||||
@ -205,14 +199,17 @@ pub trait RoomEvent: Event {
|
|||||||
/// The unique identifier for the event.
|
/// The unique identifier for the event.
|
||||||
fn event_id(&self) -> &EventId;
|
fn event_id(&self) -> &EventId;
|
||||||
|
|
||||||
|
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
||||||
|
fn origin_server_ts(&self) -> u64;
|
||||||
|
|
||||||
/// The unique identifier for the room associated with this event.
|
/// The unique identifier for the room associated with this event.
|
||||||
fn room_id(&self) -> &RoomId;
|
fn room_id(&self) -> &RoomId;
|
||||||
|
|
||||||
|
/// The unique identifier for the user who sent this event.
|
||||||
|
fn sender(&self) -> &UserId;
|
||||||
|
|
||||||
/// Additional key-value pairs not signed by the homeserver.
|
/// Additional key-value pairs not signed by the homeserver.
|
||||||
fn unsigned(&self) -> Option<&Value>;
|
fn unsigned(&self) -> Option<&Value>;
|
||||||
|
|
||||||
/// The unique identifier for the user associated with this event.
|
|
||||||
fn user_id(&self) -> &UserId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event that describes persistent state about a room.
|
/// An event that describes persistent state about a room.
|
||||||
|
@ -90,6 +90,9 @@ macro_rules! room_event {
|
|||||||
#[serde(rename="type")]
|
#[serde(rename="type")]
|
||||||
pub event_type: $crate::EventType,
|
pub event_type: $crate::EventType,
|
||||||
|
|
||||||
|
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
||||||
|
pub origin_server_ts: u64,
|
||||||
|
|
||||||
/// The unique identifier for the room associated with this event.
|
/// The unique identifier for the room associated with this event.
|
||||||
pub room_id: ::ruma_identifiers::RoomId,
|
pub room_id: ::ruma_identifiers::RoomId,
|
||||||
|
|
||||||
@ -97,9 +100,8 @@ macro_rules! room_event {
|
|||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub unsigned: Option<::serde_json::Value>,
|
pub unsigned: Option<::serde_json::Value>,
|
||||||
|
|
||||||
/// The unique identifier for the user associated with this event.
|
/// The unique identifier for the user who sent this event.
|
||||||
#[serde(rename="sender")]
|
pub sender: ::ruma_identifiers::UserId,
|
||||||
pub user_id: ::ruma_identifiers::UserId,
|
|
||||||
|
|
||||||
$(
|
$(
|
||||||
$(#[$field_attr])*
|
$(#[$field_attr])*
|
||||||
@ -120,6 +122,10 @@ macro_rules! impl_room_event {
|
|||||||
&self.event_id
|
&self.event_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn origin_server_ts(&self) -> u64 {
|
||||||
|
self.origin_server_ts
|
||||||
|
}
|
||||||
|
|
||||||
fn room_id(&self) -> &::ruma_identifiers::RoomId {
|
fn room_id(&self) -> &::ruma_identifiers::RoomId {
|
||||||
&self.room_id
|
&self.room_id
|
||||||
}
|
}
|
||||||
@ -128,8 +134,8 @@ macro_rules! impl_room_event {
|
|||||||
self.unsigned.as_ref()
|
self.unsigned.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn user_id(&self) -> &::ruma_identifiers::UserId {
|
fn sender(&self) -> &::ruma_identifiers::UserId {
|
||||||
&self.user_id
|
&self.sender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,6 +164,9 @@ macro_rules! state_event {
|
|||||||
#[serde(rename="type")]
|
#[serde(rename="type")]
|
||||||
pub event_type: $crate::EventType,
|
pub event_type: $crate::EventType,
|
||||||
|
|
||||||
|
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
||||||
|
pub origin_server_ts: u64,
|
||||||
|
|
||||||
/// The previous content for this state key, if any.
|
/// The previous content for this state key, if any.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub prev_content: Option<$content_type>,
|
pub prev_content: Option<$content_type>,
|
||||||
@ -173,8 +182,7 @@ macro_rules! state_event {
|
|||||||
pub unsigned: Option<::serde_json::Value>,
|
pub unsigned: Option<::serde_json::Value>,
|
||||||
|
|
||||||
/// The unique identifier for the user associated with this event.
|
/// The unique identifier for the user associated with this event.
|
||||||
#[serde(rename="sender")]
|
pub sender: ::ruma_identifiers::UserId,
|
||||||
pub user_id: ::ruma_identifiers::UserId,
|
|
||||||
|
|
||||||
$(
|
$(
|
||||||
$(#[$field_attr])*
|
$(#[$field_attr])*
|
||||||
|
@ -25,7 +25,7 @@ pub struct PresenceEventContent {
|
|||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
|
|
||||||
/// The last time since this used performed some action, in milliseconds.
|
/// The last time since this user performed some action, in milliseconds.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub last_active_ago: Option<u64>,
|
pub last_active_ago: Option<u64>,
|
||||||
|
|
||||||
|
@ -14,5 +14,6 @@ pub struct CreateEventContent {
|
|||||||
/// The `user_id` of the room creator. This is set by the homeserver.
|
/// The `user_id` of the room creator. This is set by the homeserver.
|
||||||
pub creator: UserId,
|
pub creator: UserId,
|
||||||
/// Whether or not this room's data should be transferred to other homeservers.
|
/// Whether or not this room's data should be transferred to other homeservers.
|
||||||
|
#[serde(rename="m.federate")]
|
||||||
pub federate: Option<bool>,
|
pub federate: Option<bool>,
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,11 @@ pub struct MemberEventContent {
|
|||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
|
|
||||||
|
/// Flag indicating if the room containing this event was created
|
||||||
|
/// with the intention of being a direct chat.
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub is_direct: Option<bool>,
|
||||||
|
|
||||||
/// The membership state of this user.
|
/// The membership state of this user.
|
||||||
pub membership: MembershipState,
|
pub membership: MembershipState,
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
use serde_json::{Value, from_value};
|
use serde_json::{Value, from_value};
|
||||||
|
|
||||||
use super::ImageInfo;
|
use super::{ImageInfo, ThumbnailInfo};
|
||||||
|
|
||||||
room_event! {
|
room_event! {
|
||||||
/// A message sent to a room.
|
/// A message sent to a room.
|
||||||
@ -118,17 +118,13 @@ pub struct FileMessageEventContent {
|
|||||||
/// A human-readable description of the file. This is recommended to be the filename of the
|
/// A human-readable description of the file. This is recommended to be the filename of the
|
||||||
/// original upload.
|
/// original upload.
|
||||||
pub body: String,
|
pub body: String,
|
||||||
|
/// The original filename of the uploaded file.
|
||||||
|
pub filename: String,
|
||||||
/// Metadata about the file referred to in `url`.
|
/// Metadata about the file referred to in `url`.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub info: Option<FileInfo>,
|
pub info: Option<FileInfo>,
|
||||||
/// The message type. Always *m.file*.
|
/// The message type. Always *m.file*.
|
||||||
pub msgtype: MessageType,
|
pub msgtype: MessageType,
|
||||||
/// Metadata about the image referred to in `thumbnail_url`.
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub thumbnail_info: Option<ImageInfo>,
|
|
||||||
/// The URL to the thumbnail of the file.
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub thumbnail_url: Option<String>,
|
|
||||||
/// The URL to the file.
|
/// The URL to the file.
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
@ -140,6 +136,12 @@ pub struct FileInfo {
|
|||||||
pub mimetype: String,
|
pub mimetype: String,
|
||||||
/// The size of the file in bytes.
|
/// The size of the file in bytes.
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
|
/// Metadata about the image referred to in `thumbnail_url`.
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub thumbnail_info: Option<ThumbnailInfo>,
|
||||||
|
/// The URL to the thumbnail of the file.
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub thumbnail_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The payload of an image message.
|
/// The payload of an image message.
|
||||||
@ -153,12 +155,6 @@ pub struct ImageMessageEventContent {
|
|||||||
pub info: Option<ImageInfo>,
|
pub info: Option<ImageInfo>,
|
||||||
/// The message type. Always *m.image*.
|
/// The message type. Always *m.image*.
|
||||||
pub msgtype: MessageType,
|
pub msgtype: MessageType,
|
||||||
/// Metadata about the image referred to in `thumbnail_url`.
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub thumbnail_info: Option<ImageInfo>,
|
|
||||||
/// The URL to the thumbnail of the image.
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub thumbnail_url: Option<String>,
|
|
||||||
/// The URL to the image.
|
/// The URL to the image.
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
@ -173,9 +169,17 @@ pub struct LocationMessageEventContent {
|
|||||||
pub geo_uri: String,
|
pub geo_uri: String,
|
||||||
/// The message type. Always *m.location*.
|
/// The message type. Always *m.location*.
|
||||||
pub msgtype: MessageType,
|
pub msgtype: MessageType,
|
||||||
|
/// Info about the location being represented.
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub info: Option<LocationInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Thumbnail info associated with a location.
|
||||||
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||||
|
pub struct LocationInfo {
|
||||||
/// Metadata about the image referred to in `thumbnail_url`.
|
/// Metadata about the image referred to in `thumbnail_url`.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub thumbnail_info: Option<ImageInfo>,
|
pub thumbnail_info: Option<ThumbnailInfo>,
|
||||||
/// The URL to a thumbnail of the location being represented.
|
/// The URL to a thumbnail of the location being represented.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub thumbnail_url: Option<String>,
|
pub thumbnail_url: Option<String>,
|
||||||
@ -232,7 +236,7 @@ pub struct VideoInfo {
|
|||||||
pub size: Option<u64>,
|
pub size: Option<u64>,
|
||||||
/// Metadata about an image.
|
/// Metadata about an image.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub thumbnail_info: Option<ImageInfo>,
|
pub thumbnail_info: Option<ThumbnailInfo>,
|
||||||
/// The URL to a thumbnail of the video clip.
|
/// The URL to a thumbnail of the video clip.
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub thumbnail_url: Option<String>,
|
pub thumbnail_url: Option<String>,
|
||||||
|
@ -27,7 +27,28 @@ pub struct ImageInfo {
|
|||||||
pub mimetype: String,
|
pub mimetype: String,
|
||||||
/// The file size of the image in bytes.
|
/// The file size of the image in bytes.
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
|
/// Metadata about the image referred to in `thumbnail_url`.
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub thumbnail_info: Option<ThumbnailInfo>,
|
||||||
|
/// The URL to the thumbnail of the image.
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub thumbnail_url: Option<String>,
|
||||||
/// The width of the image in pixels.
|
/// The width of the image in pixels.
|
||||||
#[serde(rename="w")]
|
#[serde(rename="w")]
|
||||||
pub width: u64,
|
pub width: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Metadata about a thumbnail.
|
||||||
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||||
|
pub struct ThumbnailInfo {
|
||||||
|
/// The height of the thumbnail in pixels.
|
||||||
|
#[serde(rename="h")]
|
||||||
|
pub height: u64,
|
||||||
|
/// The MIME type of the thumbnail, e.g. "image/png."
|
||||||
|
pub mimetype: String,
|
||||||
|
/// The file size of the thumbnail in bytes.
|
||||||
|
pub size: u64,
|
||||||
|
/// The width of the thumbnail in pixels.
|
||||||
|
#[serde(rename="w")]
|
||||||
|
pub width: u64,
|
||||||
|
}
|
||||||
|
@ -294,7 +294,14 @@ mod tests {
|
|||||||
"h": 128,
|
"h": 128,
|
||||||
"w": 128,
|
"w": 128,
|
||||||
"mimetype": "image/jpeg",
|
"mimetype": "image/jpeg",
|
||||||
"size": 1024
|
"size": 1024,
|
||||||
|
"thumbnail_info": {
|
||||||
|
"h": 16,
|
||||||
|
"w": 16,
|
||||||
|
"mimetype": "image/jpeg",
|
||||||
|
"size": 32
|
||||||
|
},
|
||||||
|
"thumbnail_url": "https://domain.com/image-thumbnail.jpg"
|
||||||
},
|
},
|
||||||
"thumbnail_info": {
|
"thumbnail_info": {
|
||||||
"h": 16,
|
"h": 16,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Types for the *m.typing* event.
|
//! Types for the *m.typing* event.
|
||||||
|
|
||||||
use ruma_identifiers::{EventId, RoomId};
|
use ruma_identifiers::{RoomId, UserId};
|
||||||
|
|
||||||
event! {
|
event! {
|
||||||
/// Informs the client of the list of users currently typing.
|
/// Informs the client of the list of users currently typing.
|
||||||
@ -14,5 +14,5 @@ event! {
|
|||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct TypingEventContent {
|
pub struct TypingEventContent {
|
||||||
/// The list of user IDs typing in this room, if any.
|
/// The list of user IDs typing in this room, if any.
|
||||||
pub user_ids: Vec<EventId>,
|
pub user_ids: Vec<UserId>,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user