From 0520ec8ab76cd1a6b018b4cfae10362731b932c0 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 20 Jul 2020 17:37:37 +0200 Subject: [PATCH] implement videochat-getters --- examples/repl/cmdline.rs | 11 ++++++++++- src/message.rs | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 03b17ca4b..da3216574 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -183,7 +183,7 @@ async fn log_msg(context: &Context, prefix: impl AsRef, msg: &Message) { let temp2 = dc_timestamp_to_str(msg.get_timestamp()); let msgtext = msg.get_text(); println!( - "{}{}{}{}: {} (Contact#{}): {} {}{}{}{}{} [{}]", + "{}{}{}{}: {} (Contact#{}): {} {}{}{}{}{}{} [{}]", prefix.as_ref(), msg.get_id(), if msg.get_showpadlock() { "🔒" } else { "" }, @@ -202,6 +202,15 @@ async fn log_msg(context: &Context, prefix: impl AsRef, msg: &Message) { "[FRESH]" }, if msg.is_info() { "[INFO]" } else { "" }, + if msg.get_viewtype() == Viewtype::VideochatInvitation { + format!( + "[VIDEOCHAT-INVITATION: {}, basic={}]", + msg.get_videochat_url().await.unwrap_or_default(), + msg.is_basic_videochat() + ) + } else { + "".to_string() + }, if msg.is_forwarded() { "[FORWARDED]" } else { diff --git a/src/message.rs b/src/message.rs index 050e6cd17..e8b3f6148 100644 --- a/src/message.rs +++ b/src/message.rs @@ -639,11 +639,17 @@ impl Message { } pub async fn get_videochat_url(&self) -> Option { - None + if self.viewtype == Viewtype::VideochatInvitation { + self.param.get(Param::VideochatUrl).map(|s| s.to_string()) + } else { + None + } } pub fn is_basic_videochat(&self) -> bool { - false + // currently, all videochat-urls are of type basic-webrtc + self.viewtype == Viewtype::VideochatInvitation + && self.param.get(Param::VideochatUrl).is_some() } pub fn set_text(&mut self, text: Option) {