events: Add missing version field to CallNegotiateEventContent

This commit is contained in:
Kévin Commaille 2023-05-24 16:31:38 +02:00 committed by Kévin Commaille
parent 854d8076ef
commit 60ed2c7b9a
2 changed files with 20 additions and 3 deletions

View File

@ -7,7 +7,7 @@ use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::SessionDescription; use super::SessionDescription;
use crate::OwnedVoipId; use crate::{OwnedVoipId, VoipVersionId};
/// **Added in VoIP version 1.** The content of an `m.call.negotiate` event. /// **Added in VoIP version 1.** The content of an `m.call.negotiate` event.
/// ///
@ -29,6 +29,9 @@ pub struct CallNegotiateEventContent {
/// this session. /// this session.
pub party_id: OwnedVoipId, 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. /// The time in milliseconds that the negotiation is valid for.
pub lifetime: UInt, pub lifetime: UInt,
@ -42,9 +45,21 @@ impl CallNegotiateEventContent {
pub fn new( pub fn new(
call_id: OwnedVoipId, call_id: OwnedVoipId,
party_id: OwnedVoipId, party_id: OwnedVoipId,
version: VoipVersionId,
lifetime: UInt, lifetime: UInt,
description: SessionDescription, description: SessionDescription,
) -> Self { ) -> Self {
Self { call_id, party_id, lifetime, description } 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::new(call_id, party_id, VoipVersionId::V1, lifetime, description)
} }
} }

View File

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