mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
prefix webrtc_instance by type, unify naming
This commit is contained in:
@@ -318,9 +318,11 @@ char* dc_get_blobdir (const dc_context_t* context);
|
|||||||
* The library uses the `media_quality` setting to use different defaults
|
* The library uses the `media_quality` setting to use different defaults
|
||||||
* for recoding images sent with type DC_MSG_IMAGE.
|
* for recoding images sent with type DC_MSG_IMAGE.
|
||||||
* If needed, recoding other file types is up to the UI.
|
* If needed, recoding other file types is up to the UI.
|
||||||
* - `webrtc_instance` = address to webrtc instance to use for videochats,
|
* - `webrtc_instance` = webrtc instance to use for videochats in the form
|
||||||
* eg. a server as of https://github.com/cracker0dks/basicwebrtc.
|
* `[basicwebrtc:]https://example.com/subdir#roomname=$ROOM`
|
||||||
* Format: https://example.com/subdir#roomname=$ROOM
|
* if the url is prefixed by `basicwebrtc`, the server is assumed to be of the type
|
||||||
|
* https://github.com/cracker0dks/basicwebrtc which some UIs have native support for.
|
||||||
|
* If no type is prefixed, the videochat is handled completely in a browser.
|
||||||
*
|
*
|
||||||
* If you want to retrieve a value, use dc_get_config().
|
* If you want to retrieve a value, use dc_get_config().
|
||||||
*
|
*
|
||||||
|
|||||||
14
src/chat.rs
14
src/chat.rs
@@ -1619,22 +1619,24 @@ pub async fn send_videochat_invitation(context: &Context, chat_id: ChatId) -> Re
|
|||||||
chat_id
|
chat_id
|
||||||
);
|
);
|
||||||
|
|
||||||
let url = if let Some(webrtc_instance) = context.get_config(Config::WebrtcInstance).await {
|
let instance = if let Some(instance) = context.get_config(Config::WebrtcInstance).await {
|
||||||
webrtc_instance
|
instance
|
||||||
} else {
|
} else {
|
||||||
bail!("webrtc_instance not set");
|
bail!("webrtc_instance not set");
|
||||||
};
|
};
|
||||||
|
|
||||||
let room = dc_create_id();
|
let room = dc_create_id();
|
||||||
|
|
||||||
let url = if url.contains("$ROOM") {
|
let instance = if instance.contains("$ROOM") {
|
||||||
url.replace("$ROOM", &room)
|
instance.replace("$ROOM", &room)
|
||||||
} else {
|
} else {
|
||||||
format!("{}{}", url, room)
|
format!("{}{}", instance, room)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let url = instance.replace("basicwebrtc:", "");
|
||||||
|
|
||||||
let mut msg = Message::new(Viewtype::VideochatInvitation);
|
let mut msg = Message::new(Viewtype::VideochatInvitation);
|
||||||
msg.param.set(Param::VideochatUrl, &url);
|
msg.param.set(Param::WebrtcInstance, &instance);
|
||||||
msg.text = Some(
|
msg.text = Some(
|
||||||
context
|
context
|
||||||
.stock_string_repl_str(StockMessage::VideochatInviteMsgBody, url)
|
.stock_string_repl_str(StockMessage::VideochatInviteMsgBody, url)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub enum HeaderDef {
|
|||||||
ChatContent,
|
ChatContent,
|
||||||
ChatDuration,
|
ChatDuration,
|
||||||
ChatDispositionNotificationTo,
|
ChatDispositionNotificationTo,
|
||||||
ChatVideochatUrl,
|
ChatWebrtcInstance,
|
||||||
Autocrypt,
|
Autocrypt,
|
||||||
AutocryptSetupMessage,
|
AutocryptSetupMessage,
|
||||||
SecureJoin,
|
SecureJoin,
|
||||||
|
|||||||
@@ -640,16 +640,20 @@ impl Message {
|
|||||||
|
|
||||||
pub async fn get_videochat_url(&self) -> Option<String> {
|
pub async fn get_videochat_url(&self) -> Option<String> {
|
||||||
if self.viewtype == Viewtype::VideochatInvitation {
|
if self.viewtype == Viewtype::VideochatInvitation {
|
||||||
self.param.get(Param::VideochatUrl).map(|s| s.to_string())
|
if let Some(instance) = self.param.get(Param::WebrtcInstance) {
|
||||||
} else {
|
return Some(instance.replace("basicwebrtc:", ""));
|
||||||
None
|
}
|
||||||
}
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_basic_videochat(&self) -> bool {
|
pub fn is_basic_videochat(&self) -> bool {
|
||||||
// currently, all videochat-urls are of type basic-webrtc
|
if self.viewtype == Viewtype::VideochatInvitation {
|
||||||
self.viewtype == Viewtype::VideochatInvitation
|
if let Some(instance) = self.param.get(Param::WebrtcInstance) {
|
||||||
&& self.param.get(Param::VideochatUrl).is_some()
|
return instance.starts_with("basicwebrtc:");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_text(&mut self, text: Option<String>) {
|
pub fn set_text(&mut self, text: Option<String>) {
|
||||||
|
|||||||
@@ -881,10 +881,10 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
|||||||
"videochat-invitation".into(),
|
"videochat-invitation".into(),
|
||||||
));
|
));
|
||||||
protected_headers.push(Header::new(
|
protected_headers.push(Header::new(
|
||||||
"Chat-Videochat-Url".into(),
|
"Chat-Webrtc-Instance".into(),
|
||||||
self.msg
|
self.msg
|
||||||
.param
|
.param
|
||||||
.get(Param::VideochatUrl)
|
.get(Param::WebrtcInstance)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.into(),
|
.into(),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -245,10 +245,11 @@ impl MimeMessage {
|
|||||||
fn parse_videochat_headers(&mut self) {
|
fn parse_videochat_headers(&mut self) {
|
||||||
if let Some(value) = self.get(HeaderDef::ChatContent).cloned() {
|
if let Some(value) = self.get(HeaderDef::ChatContent).cloned() {
|
||||||
if value == "videochat-invitation" {
|
if value == "videochat-invitation" {
|
||||||
let url = self.get(HeaderDef::ChatVideochatUrl).cloned();
|
let instance = self.get(HeaderDef::ChatWebrtcInstance).cloned();
|
||||||
if let Some(part) = self.parts.first_mut() {
|
if let Some(part) = self.parts.first_mut() {
|
||||||
part.typ = Viewtype::VideochatInvitation;
|
part.typ = Viewtype::VideochatInvitation;
|
||||||
part.param.set(Param::VideochatUrl, url.unwrap_or_default());
|
part.param
|
||||||
|
.set(Param::WebrtcInstance, instance.unwrap_or_default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1473,7 +1474,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
mimeparser.parts[0]
|
mimeparser.parts[0]
|
||||||
.param
|
.param
|
||||||
.get(Param::VideochatUrl)
|
.get(Param::WebrtcInstance)
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
"https://example.org/p2p/?roomname=6HiduoAn4xN"
|
"https://example.org/p2p/?roomname=6HiduoAn4xN"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ pub enum Param {
|
|||||||
AttachGroupImage = b'A',
|
AttachGroupImage = b'A',
|
||||||
|
|
||||||
/// For Messages
|
/// For Messages
|
||||||
VideochatUrl = b'V',
|
WebrtcInstance = b'V',
|
||||||
|
|
||||||
/// For Messages: space-separated list of messaged IDs of forwarded copies.
|
/// For Messages: space-separated list of messaged IDs of forwarded copies.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Date: Mon, 20 Jul 2020 14:28:30 +0000
|
|||||||
X-Mailer: Delta Chat Core 1.40.0/CLI
|
X-Mailer: Delta Chat Core 1.40.0/CLI
|
||||||
Chat-Version: 1.0
|
Chat-Version: 1.0
|
||||||
Chat-Content: videochat-invitation
|
Chat-Content: videochat-invitation
|
||||||
Chat-Videochat-Url: https://example.org/p2p/?roomname=6HiduoAn4xN
|
Chat-Webrtc-Instance: https://example.org/p2p/?roomname=6HiduoAn4xN
|
||||||
To: <tunis3@example.org>
|
To: <tunis3@example.org>
|
||||||
From: "=?utf-8?q??=" <tunis4@example.org>
|
From: "=?utf-8?q??=" <tunis4@example.org>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user