Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events: Add missing version field to CallNegotiateEventContent #1552

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}
}
4 changes: 3 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 All @@ -479,6 +480,7 @@ mod msc2746 {
"content": {
"call_id": "abcdef",
"party_id": "9876",
"version": "1",
"lifetime": 30000,
"description": {
"type": "pranswer",
Expand Down