mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
send out videochat-invitation message, set up fallback text
This commit is contained in:
32
src/chat.rs
32
src/chat.rs
@@ -1611,6 +1611,38 @@ pub async fn send_text_msg(
|
||||
send_msg(context, chat_id, &mut msg).await
|
||||
}
|
||||
|
||||
pub async fn send_videochat_invitation(context: &Context, chat_id: ChatId) -> Result<MsgId, Error> {
|
||||
ensure!(
|
||||
!chat_id.is_special(),
|
||||
"videochat invitation cannot be sent to special chat: {}",
|
||||
chat_id
|
||||
);
|
||||
|
||||
let url = if let Some(basic_webrtc_instance) =
|
||||
context.get_config(Config::BasicWebrtcInstance).await
|
||||
{
|
||||
basic_webrtc_instance
|
||||
} else {
|
||||
bail!("basic_webrtc_instance not set");
|
||||
};
|
||||
|
||||
let room = dc_create_id();
|
||||
|
||||
let url = if url.contains("$ROOM") {
|
||||
url.replace("$ROOM", &room)
|
||||
} else {
|
||||
format!("{}{}", url, room)
|
||||
};
|
||||
|
||||
let mut msg = Message::new(Viewtype::Text);
|
||||
msg.text = Some(
|
||||
context
|
||||
.stock_string_repl_str(StockMessage::VideochatInviteMsgBody, url)
|
||||
.await,
|
||||
);
|
||||
send_msg(context, chat_id, &mut msg).await
|
||||
}
|
||||
|
||||
pub async fn get_chat_msgs(
|
||||
context: &Context,
|
||||
chat_id: ChatId,
|
||||
|
||||
@@ -638,6 +638,14 @@ impl Message {
|
||||
None
|
||||
}
|
||||
|
||||
pub async fn get_videochat_url(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_basic_videochat(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn set_text(&mut self, text: Option<String>) {
|
||||
self.text = text;
|
||||
}
|
||||
|
||||
@@ -210,6 +210,12 @@ pub enum StockMessage {
|
||||
|
||||
#[strum(props(fallback = "Message deletion timer is set to 4 weeks."))]
|
||||
MsgEphemeralTimerFourWeeks = 81,
|
||||
|
||||
#[strum(props(fallback = "Videochat invitation"))]
|
||||
VideochatInvitation = 82,
|
||||
|
||||
#[strum(props(fallback = "You are invited to an videochat, click %1$s to join."))]
|
||||
VideochatInviteMsgBody = 83,
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user