Skip to content

Commit

Permalink
events: Add missing version field to CallNegotiateEventContent
Browse files Browse the repository at this point in the history
  • Loading branch information
zecakeh committed May 24, 2023
1 parent 77454b7 commit 54bc104
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions crates/ruma-common/src/events/call/negotiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};

use super::SessionDescription;
use crate::OwnedVoipId;
use crate::{OwnedVoipId, VoipVersionId};

/// **Added in VoIP version 1.** The content of an `m.call.negotiate` event.
///
Expand All @@ -29,6 +29,9 @@ pub struct CallNegotiateEventContent {
/// this session.
pub party_id: OwnedVoipId,

/// The version of the VoIP specification this messages adheres to.
pub version: VoipVersionId,

/// The time in milliseconds that the negotiation is valid for.
pub lifetime: UInt,

Expand All @@ -40,11 +43,23 @@ impl CallNegotiateEventContent {
/// Creates a `CallNegotiateEventContent` with the given call ID, party ID, lifetime and
/// description.
pub fn new(
call_id: OwnedVoipId,
party_id: OwnedVoipId,
version: VoipVersionId,
lifetime: UInt,
description: SessionDescription,
) -> Self {
Self { call_id, party_id, version, lifetime, description }
}

/// Convenience method to create a version 1 `CallNegotiateEventContent` with all the required
/// fields.
pub fn version_1(
call_id: OwnedVoipId,
party_id: OwnedVoipId,
lifetime: UInt,
description: SessionDescription,
) -> Self {
Self { call_id, party_id, lifetime, description }
Self::new(call_id, party_id, VoipVersionId::V1, lifetime, description)
}
}
3 changes: 2 additions & 1 deletion crates/ruma-common/tests/events/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ mod msc2746 {

#[test]
fn negotiate_event_serialization() {
let content = CallNegotiateEventContent::new(
let content = CallNegotiateEventContent::version_1(
"abcdef".into(),
"9876".into(),
uint!(30000),
Expand All @@ -464,6 +464,7 @@ mod msc2746 {
json!({
"call_id": "abcdef",
"party_id": "9876",
"version": "1",
"lifetime": 30000,
"description": {
"type": "offer",
Expand Down

0 comments on commit 54bc104

Please sign in to comment.