mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
parse incoming videochat-invitations and mark messages as such
This commit is contained in:
@@ -35,6 +35,7 @@ pub enum HeaderDef {
|
|||||||
ChatContent,
|
ChatContent,
|
||||||
ChatDuration,
|
ChatDuration,
|
||||||
ChatDispositionNotificationTo,
|
ChatDispositionNotificationTo,
|
||||||
|
ChatVideochatUrl,
|
||||||
Autocrypt,
|
Autocrypt,
|
||||||
AutocryptSetupMessage,
|
AutocryptSetupMessage,
|
||||||
SecureJoin,
|
SecureJoin,
|
||||||
|
|||||||
@@ -242,6 +242,18 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_videochat_headers(&mut self) {
|
||||||
|
if let Some(value) = self.get(HeaderDef::ChatContent).cloned() {
|
||||||
|
if value == "videochat-invitation" {
|
||||||
|
let url = self.get(HeaderDef::ChatVideochatUrl).cloned();
|
||||||
|
if let Some(part) = self.parts.first_mut() {
|
||||||
|
part.typ = Viewtype::VideochatInvitation;
|
||||||
|
part.param.set(Param::VideochatUrl, url.unwrap_or_default());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Squashes mutlipart chat messages with attachment into single-part messages.
|
/// Squashes mutlipart chat messages with attachment into single-part messages.
|
||||||
///
|
///
|
||||||
/// Delta Chat sends attachments, such as images, in two-part messages, with the first message
|
/// Delta Chat sends attachments, such as images, in two-part messages, with the first message
|
||||||
@@ -314,6 +326,7 @@ impl MimeMessage {
|
|||||||
fn parse_headers(&mut self, context: &Context) -> Result<()> {
|
fn parse_headers(&mut self, context: &Context) -> Result<()> {
|
||||||
self.parse_system_message_headers(context)?;
|
self.parse_system_message_headers(context)?;
|
||||||
self.parse_avatar_headers();
|
self.parse_avatar_headers();
|
||||||
|
self.parse_videochat_headers();
|
||||||
self.squash_attachment_parts();
|
self.squash_attachment_parts();
|
||||||
|
|
||||||
if let Some(ref subject) = self.get_subject() {
|
if let Some(ref subject) = self.get_subject() {
|
||||||
@@ -1449,6 +1462,28 @@ mod tests {
|
|||||||
assert!(mimeparser.group_avatar.unwrap().is_change());
|
assert!(mimeparser.group_avatar.unwrap().is_change());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_mimeparser_with_videochat() {
|
||||||
|
let t = TestContext::new().await;
|
||||||
|
|
||||||
|
let raw = include_bytes!("../test-data/message/videochat_invitation.eml");
|
||||||
|
let mimeparser = MimeMessage::from_bytes(&t.ctx, &raw[..]).await.unwrap();
|
||||||
|
assert_eq!(mimeparser.parts.len(), 1);
|
||||||
|
assert_eq!(mimeparser.parts[0].typ, Viewtype::VideochatInvitation);
|
||||||
|
assert_eq!(
|
||||||
|
mimeparser.parts[0]
|
||||||
|
.param
|
||||||
|
.get(Param::VideochatUrl)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
"https://example.org/p2p/?roomname=6HiduoAn4xN"
|
||||||
|
);
|
||||||
|
assert!(mimeparser.parts[0]
|
||||||
|
.msg
|
||||||
|
.contains("https://example.org/p2p/?roomname=6HiduoAn4xN"));
|
||||||
|
assert_eq!(mimeparser.user_avatar, None);
|
||||||
|
assert_eq!(mimeparser.group_avatar, None);
|
||||||
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_mimeparser_message_kml() {
|
async fn test_mimeparser_message_kml() {
|
||||||
let context = TestContext::new().await;
|
let context = TestContext::new().await;
|
||||||
|
|||||||
15
test-data/message/videochat_invitation.eml
Normal file
15
test-data/message/videochat_invitation.eml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Content-Type: text/plain; charset=utf-8
|
||||||
|
Subject: Message from user
|
||||||
|
Message-ID: <Mr.f1O61111evx.ikocf333353@example.org>
|
||||||
|
Date: Mon, 20 Jul 2020 14:28:30 +0000
|
||||||
|
X-Mailer: Delta Chat Core 1.40.0/CLI
|
||||||
|
Chat-Version: 1.0
|
||||||
|
Chat-Content: videochat-invitation
|
||||||
|
Chat-Videochat-Url: https://example.org/p2p/?roomname=6HiduoAn4xN
|
||||||
|
To: <tunis3@example>
|
||||||
|
From: "=?utf-8?q??=" <tunis4@example.org>
|
||||||
|
|
||||||
|
You are invited to an videochat, click https://example.org/p2p/?roomname=6HiduoAn4xN to join.
|
||||||
|
|
||||||
|
--
|
||||||
|
Sent with my Delta Chat Messenger: https://delta.chat
|
||||||
Reference in New Issue
Block a user