diff --git a/src/chat.rs b/src/chat.rs index 886a0aa60..96db541e6 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1629,13 +1629,7 @@ pub async fn send_videochat_invitation(context: &Context, chat_id: ChatId) -> Re bail!("webrtc_instance not set"); }; - let room = dc_create_id(); - - let instance = if instance.contains("$ROOM") { - instance.replace("$ROOM", &room) - } else { - format!("{}{}", instance, room) - }; + let instance = Message::create_webrtc_instance(&instance, &dc_create_id()); let mut msg = Message::new(Viewtype::VideochatInvitation); msg.param.set(Param::WebrtcRoom, &instance); diff --git a/src/message.rs b/src/message.rs index 092569785..1be8ae7a4 100644 --- a/src/message.rs +++ b/src/message.rs @@ -643,6 +643,16 @@ impl Message { None } + // add room to a webrtc_instance as defined by the corresponding config-value; + // the result may still be prefixed by the type + pub fn create_webrtc_instance(instance: &str, room: &str) -> String { + if instance.contains("$ROOM") { + instance.replace("$ROOM", &room) + } else { + format!("{}{}", instance, room) + } + } + /// split a webrtc_instance as defined by the corresponding config-value into a type and a url pub fn parse_webrtc_instance(instance: &str) -> (VideochatType, String) { let mut split = instance.splitn(2, ':');