Add m.room.message types.
This commit is contained in:
parent
09ecdfa470
commit
4043de42ee
185
src/room/message.rs
Normal file
185
src/room/message.rs
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
//! Types for the *m.room.message* event.
|
||||||
|
|
||||||
|
use core::EventType;
|
||||||
|
use super::ImageInfo;
|
||||||
|
|
||||||
|
/// A message sent to a room.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct MessageEvent {
|
||||||
|
pub content: MessageEventContent,
|
||||||
|
pub event_id: String,
|
||||||
|
pub event_type: EventType,
|
||||||
|
pub room_id: String,
|
||||||
|
pub user_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The message type of message event, e.g. `m.image` or `m.text`.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub enum MessageType {
|
||||||
|
Audio,
|
||||||
|
Emote,
|
||||||
|
File,
|
||||||
|
Image,
|
||||||
|
Location,
|
||||||
|
Notice,
|
||||||
|
Text,
|
||||||
|
Video,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of a message event.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub enum MessageEventContent {
|
||||||
|
Audio(AudioMessageEventContent),
|
||||||
|
Emote(EmoteMessageEventContent),
|
||||||
|
File(FileMessageEventContent),
|
||||||
|
Image(ImageMessageEventContent),
|
||||||
|
Location(LocationMessageEventContent),
|
||||||
|
Notice(NoticeMessageEventContent),
|
||||||
|
Text(TextMessageEventContent),
|
||||||
|
Video(VideoMessageEventContent),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of an audio message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct AudioMessageEventContent {
|
||||||
|
/// The textual representation of this message.
|
||||||
|
pub body: String,
|
||||||
|
/// Metadata for the audio clip referred to in `url`.
|
||||||
|
pub info: Option<AudioInfo>,
|
||||||
|
/// The message type. Always *m.audio*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
/// The URL to the audio clip.
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Metadata about an audio clip.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct AudioInfo {
|
||||||
|
/// The duration of the audio in milliseconds.
|
||||||
|
pub duration: Option<u64>,
|
||||||
|
/// The mimetype of the audio, e.g. "audio/aac."
|
||||||
|
pub mimetype: Option<String>,
|
||||||
|
/// The size of the audio clip in bytes.
|
||||||
|
pub size: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of an emote message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct EmoteMessageEventContent {
|
||||||
|
/// The emote action to perform.
|
||||||
|
pub body: String,
|
||||||
|
/// The message type. Always *m.emote*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of a file message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct FileMessageEventContent {
|
||||||
|
/// A human-readable description of the file. This is recommended to be the filename of the
|
||||||
|
/// original upload.
|
||||||
|
pub body: String,
|
||||||
|
/// Metadata about the file referred to in `url`.
|
||||||
|
pub info: Option<FileInfo>,
|
||||||
|
/// The message type. Always *m.file*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
/// Metadata about the image referred to in `thumbnail_url`.
|
||||||
|
pub thumbnail_info: Option<ImageInfo>,
|
||||||
|
/// The URL to the thumbnail of the file.
|
||||||
|
pub thumbnail_url: Option<String>,
|
||||||
|
/// The URL to the file.
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Metadata about a file.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct FileInfo {
|
||||||
|
/// The mimetype of the file, e.g. "application/msword."
|
||||||
|
pub mimetype: String,
|
||||||
|
/// The size of the file in bytes.
|
||||||
|
pub size: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of an image message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct ImageMessageEventContent {
|
||||||
|
/// A textual representation of the image. This could be the alt text of the image, the filename
|
||||||
|
/// of the image, or some kind of content description for accessibility e.g. "image attachment."
|
||||||
|
pub body: String,
|
||||||
|
/// Metadata about the image referred to in `url`.
|
||||||
|
pub info: Option<ImageInfo>,
|
||||||
|
/// The message type. Always *m.image*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
/// Metadata about the image referred to in `thumbnail_url`.
|
||||||
|
pub thumbnail_info: Option<ImageInfo>,
|
||||||
|
/// The URL to the thumbnail of the image.
|
||||||
|
pub thumbnail_url: Option<String>,
|
||||||
|
/// The URL to the image.
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of a location message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct LocationMessageEventContent {
|
||||||
|
/// A description of the location e.g. "Big Ben, London, UK,"or some kind of content description
|
||||||
|
/// for accessibility, e.g. "location attachment."
|
||||||
|
pub body: String,
|
||||||
|
/// A geo URI representing the location.
|
||||||
|
pub geo_uri: String,
|
||||||
|
/// The message type. Always *m.location*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
/// Metadata about the image referred to in `thumbnail_url`.
|
||||||
|
pub thumbnail_info: Option<ImageInfo>,
|
||||||
|
/// The URL to a thumbnail of the location being represented.
|
||||||
|
pub thumbnail_url: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of a notice message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct NoticeMessageEventContent {
|
||||||
|
/// The notice text to send.
|
||||||
|
pub body: String,
|
||||||
|
/// The message type. Always *m.notice*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of a text message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct TextMessageEventContent {
|
||||||
|
/// The body of the message.
|
||||||
|
pub body: String,
|
||||||
|
/// The message type. Always *m.text*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The payload of a video message.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct VideoMessageEventContent {
|
||||||
|
/// A description of the video, e.g. "Gangnam Style," or some kind of content description for
|
||||||
|
/// accessibility, e.g. "video attachment."
|
||||||
|
pub body: String,
|
||||||
|
/// Metadata about the video clip referred to in `url`.
|
||||||
|
pub info: Option<VideoInfo>,
|
||||||
|
/// The message type. Always *m.video*.
|
||||||
|
pub msgtype: MessageType,
|
||||||
|
/// The URL to the video clip.
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Metadata about a video.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct VideoInfo {
|
||||||
|
/// The duration of the video in milliseconds.
|
||||||
|
pub duration: Option<u64>,
|
||||||
|
/// The height of the video in pixels.
|
||||||
|
pub h: Option<u64>,
|
||||||
|
/// The mimetype of the video, e.g. "video/mp4."
|
||||||
|
pub mimetype: Option<String>,
|
||||||
|
/// The size of the video in bytes.
|
||||||
|
pub size: Option<u64>,
|
||||||
|
/// Metadata about an image.
|
||||||
|
pub thumbnail_info: Option<ImageInfo>,
|
||||||
|
/// The URL to a thumbnail of the video clip.
|
||||||
|
pub thumbnail_url: Option<String>,
|
||||||
|
/// The width of the video in pixels.
|
||||||
|
pub w: Option<u64>,
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
//! Types for the *m.room.message.feedback* event.
|
|
@ -1,3 +0,0 @@
|
|||||||
//! Modules for events in the *m.room.message* namespace and types for the *m.room.message* event.
|
|
||||||
|
|
||||||
pub mod feedback;
|
|
Loading…
x
Reference in New Issue
Block a user