mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
fix: put overridden sender name into message info
This commit is contained in:
@@ -201,12 +201,14 @@ WHERE id=?;
|
||||
let fts = timestamp_to_str(msg.get_timestamp());
|
||||
ret += &format!("Sent: {fts}");
|
||||
|
||||
let name = Contact::get_by_id(context, msg.from_id)
|
||||
.await
|
||||
.map(|contact| contact.get_name_n_addr())
|
||||
.unwrap_or_default();
|
||||
|
||||
ret += &format!(" by {name}");
|
||||
let from_contact = Contact::get_by_id(context, msg.from_id).await?;
|
||||
let name = from_contact.get_name_n_addr();
|
||||
if let Some(override_sender_name) = msg.get_override_sender_name() {
|
||||
let addr = from_contact.get_addr();
|
||||
ret += &format!(" by ~{override_sender_name} ({addr})");
|
||||
} else {
|
||||
ret += &format!(" by {name}");
|
||||
}
|
||||
ret += "\n";
|
||||
|
||||
if msg.from_id != ContactId::SELF {
|
||||
|
||||
@@ -316,6 +316,9 @@ pub(crate) async fn receive_imf_inner(
|
||||
//
|
||||
// If this is a mailing list email (i.e. list_id_header is some), don't change the displayname because in
|
||||
// a mailing list the sender displayname sometimes does not belong to the sender email address.
|
||||
// For example, GitHub sends messages from `notifications@github.com`,
|
||||
// but uses display name of the user whose action generated the notification
|
||||
// as the display name.
|
||||
let (from_id, _from_id_blocked, incoming_origin) =
|
||||
match from_field_to_contact_id(context, &mime_parser.from, prevent_rename).await? {
|
||||
Some(contact_id_res) => contact_id_res,
|
||||
|
||||
@@ -4393,3 +4393,22 @@ async fn test_references() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_list_from() -> Result<()> {
|
||||
let t = &TestContext::new_alice().await;
|
||||
|
||||
let raw = include_bytes!("../../test-data/message/list-from.eml");
|
||||
let received = receive_imf(t, raw, false).await?.unwrap();
|
||||
let msg = Message::load_from_db(t, *received.msg_ids.last().unwrap()).await?;
|
||||
assert_eq!(msg.get_override_sender_name().unwrap(), "ÖAMTC");
|
||||
let sender_contact = Contact::get_by_id(t, msg.from_id).await?;
|
||||
assert_eq!(
|
||||
sender_contact.get_display_name(),
|
||||
"clubinfo@donotreply.oeamtc.at"
|
||||
);
|
||||
let info = msg.id.get_info(t).await?;
|
||||
assert!(info.contains("Sent: 2024.03.20 09:00:01 by ~ÖAMTC (clubinfo@donotreply.oeamtc.at)"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user