-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CallNotify event as described by MSC4075
See: [MSC4075]( matrix-org/matrix-spec-proposals#4075) Signed-off-by: Timo K <[email protected]>
- Loading branch information
Showing
6 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//! Types for matrixRTC state events ([MSC4075]). | ||
//! | ||
//! This implements the event type defined in MSC4075. | ||
//! | ||
//! [MSC3401]: https://github.com/matrix-org/matrix-spec-proposals/pull/4075 | ||
use ruma_macros::EventContent; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::member::Application; | ||
use crate::Mentions; | ||
|
||
/// The content of an `m.call.notify` event. | ||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)] | ||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||
#[ruma_event(type = "m.call.notify", kind = MessageLike)] | ||
pub struct CallNotifyEventContent { | ||
/// A unique identifier for the call. | ||
pub call_id: String, | ||
pub application: ApplicationType, | ||
pub notify_type: NotifyType, | ||
#[serde(rename = "m.mentions")] | ||
pub mentions: Mentions, | ||
} | ||
|
||
impl CallNotifyEventContent { | ||
/// Creates a new `CallHangupEventContent` with the given call ID and VoIP version. | ||
pub fn new( | ||
call_id: String, | ||
application: ApplicationType, | ||
notify_type: NotifyType, | ||
mentions: Mentions, | ||
) -> Self { | ||
Self { call_id, application, notify_type, mentions } | ||
} | ||
} | ||
|
||
/// How this notify event should notify the receiver. | ||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub enum NotifyType { | ||
/// The receiving client should ring with an audible sound. | ||
#[serde(rename = "ring")] | ||
Ring, | ||
/// The receiving client should display a visual notification. | ||
#[serde(rename = "notify")] | ||
Notify, | ||
} | ||
|
||
/// The type of matrix RTC application. | ||
/// | ||
/// This is different to [`Application`] because application contains all the information from the | ||
/// call.member event. | ||
/// | ||
/// An `Application` can be converted into an `ApplicationType`: | ||
/// ``` | ||
/// let a: Application = myApp; | ||
/// let b: ApplicationType = a.into(); | ||
/// ``` | ||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||
pub enum ApplicationType { | ||
/// A VoIP call. | ||
#[serde(rename = "m.call")] | ||
Call, | ||
} | ||
|
||
impl From<Application> for ApplicationType { | ||
fn from(val: Application) -> Self { | ||
match val { | ||
Application::Call(_) => ApplicationType::Call, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters