mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Merge pull request #1353 from deltachat/show-nondc-replies
fix showing non-dc replies
This commit is contained in:
@@ -1488,6 +1488,7 @@ fn is_known_rfc724_mid_in_list(context: &Context, mid_list: &str) -> bool {
|
|||||||
|
|
||||||
/// Check if a message is a reply to a known message (messenger or non-messenger).
|
/// Check if a message is a reply to a known message (messenger or non-messenger).
|
||||||
fn is_known_rfc724_mid(context: &Context, rfc724_mid: &str) -> bool {
|
fn is_known_rfc724_mid(context: &Context, rfc724_mid: &str) -> bool {
|
||||||
|
let rfc724_mid = rfc724_mid.trim_start_matches('<').trim_end_matches('>');
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.exists(
|
.exists(
|
||||||
@@ -1534,6 +1535,7 @@ pub(crate) fn is_msgrmsg_rfc724_mid_in_list(context: &Context, mid_list: &str) -
|
|||||||
|
|
||||||
/// Check if a message is a reply to any messenger message.
|
/// Check if a message is a reply to any messenger message.
|
||||||
fn is_msgrmsg_rfc724_mid(context: &Context, rfc724_mid: &str) -> bool {
|
fn is_msgrmsg_rfc724_mid(context: &Context, rfc724_mid: &str) -> bool {
|
||||||
|
let rfc724_mid = rfc724_mid.trim_start_matches('<').trim_end_matches('>');
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.exists(
|
.exists(
|
||||||
@@ -1623,6 +1625,7 @@ fn dc_create_incoming_rfc724_mid(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::message::Message;
|
||||||
use crate::test_utils::dummy_context;
|
use crate::test_utils::dummy_context;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1682,4 +1685,38 @@ mod tests {
|
|||||||
Some("123-45-9@stub".into())
|
Some("123-45-9@stub".into())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_is_known_rfc724_mid() {
|
||||||
|
let t = dummy_context();
|
||||||
|
let mut msg = Message::new(Viewtype::Text);
|
||||||
|
msg.text = Some("first message".to_string());
|
||||||
|
let msg_id = chat::add_device_msg(&t.ctx, None, Some(&mut msg)).unwrap();
|
||||||
|
let msg = Message::load_from_db(&t.ctx, msg_id).unwrap();
|
||||||
|
|
||||||
|
// Message-IDs may or may not be surrounded by angle brackets
|
||||||
|
assert!(is_known_rfc724_mid(
|
||||||
|
&t.ctx,
|
||||||
|
format!("<{}>", msg.rfc724_mid).as_str()
|
||||||
|
));
|
||||||
|
assert!(is_known_rfc724_mid(&t.ctx, &msg.rfc724_mid));
|
||||||
|
assert!(!is_known_rfc724_mid(&t.ctx, "nonexistant@message.id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_is_msgrmsg_rfc724_mid() {
|
||||||
|
let t = dummy_context();
|
||||||
|
let mut msg = Message::new(Viewtype::Text);
|
||||||
|
msg.text = Some("first message".to_string());
|
||||||
|
let msg_id = chat::add_device_msg(&t.ctx, None, Some(&mut msg)).unwrap();
|
||||||
|
let msg = Message::load_from_db(&t.ctx, msg_id).unwrap();
|
||||||
|
|
||||||
|
// Message-IDs may or may not be surrounded by angle brackets
|
||||||
|
assert!(is_msgrmsg_rfc724_mid(
|
||||||
|
&t.ctx,
|
||||||
|
format!("<{}>", msg.rfc724_mid).as_str()
|
||||||
|
));
|
||||||
|
assert!(is_msgrmsg_rfc724_mid(&t.ctx, &msg.rfc724_mid));
|
||||||
|
assert!(!is_msgrmsg_rfc724_mid(&t.ctx, "nonexistant@message.id"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user