mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
send out videochat-invitation message, set up fallback text
This commit is contained in:
@@ -4596,8 +4596,10 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
#define DC_STR_EPHEMERAL_DAY 79
|
#define DC_STR_EPHEMERAL_DAY 79
|
||||||
#define DC_STR_EPHEMERAL_WEEK 80
|
#define DC_STR_EPHEMERAL_WEEK 80
|
||||||
#define DC_STR_EPHEMERAL_FOUR_WEEKS 81
|
#define DC_STR_EPHEMERAL_FOUR_WEEKS 81
|
||||||
|
#define DC_STR_VIDEOCHAT_INVITATION 82
|
||||||
|
#define DC_STR_VIDEOCHAT_INVITE_MSG_BODY 83
|
||||||
|
|
||||||
#define DC_STR_COUNT 81
|
#define DC_STR_COUNT 83
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @}
|
* @}
|
||||||
|
|||||||
@@ -710,6 +710,25 @@ pub unsafe extern "C" fn dc_send_text_msg(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn dc_send_videochat_invitation(
|
||||||
|
context: *mut dc_context_t,
|
||||||
|
chat_id: u32,
|
||||||
|
) -> u32 {
|
||||||
|
if context.is_null() {
|
||||||
|
eprintln!("ignoring careless call to dc_send_videochat_invitation()");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
let ctx = &*context;
|
||||||
|
|
||||||
|
block_on(async move {
|
||||||
|
chat::send_videochat_invitation(&ctx, ChatId::new(chat_id))
|
||||||
|
.await
|
||||||
|
.map(|msg_id| msg_id.to_u32())
|
||||||
|
.unwrap_or_log_default(&ctx, "Failed to send videochat invitation")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn dc_set_draft(
|
pub unsafe extern "C" fn dc_set_draft(
|
||||||
context: *mut dc_context_t,
|
context: *mut dc_context_t,
|
||||||
@@ -2820,6 +2839,29 @@ pub unsafe extern "C" fn dc_msg_is_setupmessage(msg: *mut dc_msg_t) -> libc::c_i
|
|||||||
ffi_msg.message.is_setupmessage().into()
|
ffi_msg.message.is_setupmessage().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn dc_msg_get_videochat_url(msg: *mut dc_msg_t) -> *mut libc::c_char {
|
||||||
|
if msg.is_null() {
|
||||||
|
eprintln!("ignoring careless call to dc_msg_get_videochat_url()");
|
||||||
|
return "".strdup();
|
||||||
|
}
|
||||||
|
let ffi_msg = &*msg;
|
||||||
|
|
||||||
|
block_on(ffi_msg.message.get_videochat_url())
|
||||||
|
.unwrap_or_default()
|
||||||
|
.strdup()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn dc_msg_is_basic_videochat(msg: *mut dc_msg_t) -> libc::c_int {
|
||||||
|
if msg.is_null() {
|
||||||
|
eprintln!("ignoring careless call to dc_msg_is_basic_videochat()");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
let ffi_msg = &*msg;
|
||||||
|
ffi_msg.message.is_basic_videochat().into()
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn dc_msg_get_setupcodebegin(msg: *mut dc_msg_t) -> *mut libc::c_char {
|
pub unsafe extern "C" fn dc_msg_get_setupcodebegin(msg: *mut dc_msg_t) -> *mut libc::c_char {
|
||||||
if msg.is_null() {
|
if msg.is_null() {
|
||||||
|
|||||||
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
|
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(
|
pub async fn get_chat_msgs(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
chat_id: ChatId,
|
chat_id: ChatId,
|
||||||
|
|||||||
@@ -638,6 +638,14 @@ impl Message {
|
|||||||
None
|
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>) {
|
pub fn set_text(&mut self, text: Option<String>) {
|
||||||
self.text = text;
|
self.text = text;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,12 @@ pub enum StockMessage {
|
|||||||
|
|
||||||
#[strum(props(fallback = "Message deletion timer is set to 4 weeks."))]
|
#[strum(props(fallback = "Message deletion timer is set to 4 weeks."))]
|
||||||
MsgEphemeralTimerFourWeeks = 81,
|
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