Convert most message events from ruma_event! to derive(MessageEventContent)

* m.sticker
* m.call.answer
* m.call.candidates
* m.call.hangup
* m.call.invite
This commit is contained in:
Jonas Platte 2020-06-02 23:48:18 +02:00
parent 80ff10ae6a
commit 24f720d1f1
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
5 changed files with 67 additions and 85 deletions

View File

@ -1,16 +1,15 @@
//! Types for the *m.call.answer* event.
use js_int::UInt;
use ruma_events_macros::ruma_event;
use ruma_events_macros::{FromRaw, MessageEventContent};
use serde::Serialize;
use super::SessionDescription;
ruma_event! {
/// This event is sent by the callee when they wish to answer the call.
AnswerEvent {
kind: RoomEvent,
event_type: "m.call.answer",
content: {
/// This event is sent by the callee when they wish to answer the call.
#[derive(Clone, Debug, Serialize, FromRaw, MessageEventContent)]
#[ruma_event(type = "m.call.answer")]
pub struct AnswerEventContenet {
/// The VoIP session description object. The session description type must be *answer*.
pub answer: SessionDescription,
@ -19,6 +18,4 @@ ruma_event! {
/// The version of the VoIP specification this messages adheres to.
pub version: UInt,
},
}
}

View File

@ -1,17 +1,14 @@
//! Types for the *m.call.candidates* event.
use js_int::UInt;
use ruma_events_macros::ruma_event;
use ruma_events_macros::{FromRaw, MessageEventContent};
use serde::{Deserialize, Serialize};
ruma_event! {
/// This event is sent by callers after sending an invite and by the callee after answering.
/// Its purpose is to give the other party additional ICE candidates to try using to
/// communicate.
CandidatesEvent {
kind: RoomEvent,
event_type: "m.call.candidates",
content: {
/// This event is sent by callers after sending an invite and by the callee after answering. Its
/// purpose is to give the other party additional ICE candidates to try using to communicate.
#[derive(Clone, Debug, Serialize, FromRaw, MessageEventContent)]
#[ruma_event(type = "m.call.candidates")]
pub struct CandidatesEventContent {
/// The ID of the call this event relates to.
pub call_id: String,
@ -20,8 +17,6 @@ ruma_event! {
/// The version of the VoIP specification this messages adheres to.
pub version: UInt,
},
}
}
/// An ICE (Interactive Connectivity Establishment) candidate.

View File

@ -1,17 +1,15 @@
//! Types for the *m.call.hangup* event.
use js_int::UInt;
use ruma_events_macros::ruma_event;
use ruma_events_macros::{FromRaw, MessageEventContent};
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
ruma_event! {
/// Sent by either party to signal their termination of the call. This can be sent either once
/// the call has has been established or before to abort the call.
HangupEvent {
kind: RoomEvent,
event_type: "m.call.hangup",
content: {
/// Sent by either party to signal their termination of the call. This can be sent either once the
/// call has has been established or before to abort the call.
#[derive(Clone, Debug, Serialize, FromRaw, MessageEventContent)]
#[ruma_event(type = "m.call.hangup")]
pub struct HangupEventContent {
/// The ID of the call this event relates to.
pub call_id: String,
@ -21,8 +19,6 @@ ruma_event! {
/// Optional error reason for the hangup.
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<Reason>,
},
}
}
/// A reason for a hangup.

View File

@ -1,16 +1,15 @@
//! Types for the *m.call.invite* event.
use js_int::UInt;
use ruma_events_macros::ruma_event;
use ruma_events_macros::{FromRaw, MessageEventContent};
use serde::Serialize;
use super::SessionDescription;
ruma_event! {
/// This event is sent by the caller when they wish to establish a call.
InviteEvent {
kind: RoomEvent,
event_type: "m.call.invite",
content: {
/// This event is sent by the caller when they wish to establish a call.
#[derive(Clone, Debug, Serialize, FromRaw, MessageEventContent)]
#[ruma_event(type = "m.call.invite")]
pub struct InviteEventContent {
/// A unique identifer for the call.
pub call_id: String,
@ -24,6 +23,4 @@ ruma_event! {
/// The version of the VoIP specification this messages adheres to.
pub version: UInt,
},
}
}

View File

@ -1,15 +1,14 @@
//! Types for the *m.sticker* event.
use ruma_events_macros::ruma_event;
use ruma_events_macros::{FromRaw, MessageEventContent};
use serde::Serialize;
use crate::room::ImageInfo;
ruma_event! {
/// A sticker message.
StickerEvent {
kind: RoomEvent,
event_type: "m.sticker",
content: {
/// A sticker message.
#[derive(Clone, Debug, Serialize, FromRaw, MessageEventContent)]
#[ruma_event(type = "m.sticker")]
pub struct StickerEventContent {
/// A textual representation or associated description of the sticker image. This could
/// be the alt text of the original image, or a message to accompany and further
/// describe the sticker.
@ -20,6 +19,4 @@ ruma_event! {
/// The URL to the sticker image. This must be a valid `mxc://` URI.
pub url: String,
},
}
}