mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26: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());
|
let fts = timestamp_to_str(msg.get_timestamp());
|
||||||
ret += &format!("Sent: {fts}");
|
ret += &format!("Sent: {fts}");
|
||||||
|
|
||||||
let name = Contact::get_by_id(context, msg.from_id)
|
let from_contact = Contact::get_by_id(context, msg.from_id).await?;
|
||||||
.await
|
let name = from_contact.get_name_n_addr();
|
||||||
.map(|contact| contact.get_name_n_addr())
|
if let Some(override_sender_name) = msg.get_override_sender_name() {
|
||||||
.unwrap_or_default();
|
let addr = from_contact.get_addr();
|
||||||
|
ret += &format!(" by ~{override_sender_name} ({addr})");
|
||||||
ret += &format!(" by {name}");
|
} else {
|
||||||
|
ret += &format!(" by {name}");
|
||||||
|
}
|
||||||
ret += "\n";
|
ret += "\n";
|
||||||
|
|
||||||
if msg.from_id != ContactId::SELF {
|
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
|
// 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.
|
// 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) =
|
let (from_id, _from_id_blocked, incoming_origin) =
|
||||||
match from_field_to_contact_id(context, &mime_parser.from, prevent_rename).await? {
|
match from_field_to_contact_id(context, &mime_parser.from, prevent_rename).await? {
|
||||||
Some(contact_id_res) => contact_id_res,
|
Some(contact_id_res) => contact_id_res,
|
||||||
|
|||||||
@@ -4393,3 +4393,22 @@ async fn test_references() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
|
|||||||
28
test-data/message/list-from.eml
Normal file
28
test-data/message/list-from.eml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Return-Path: <wwwrun@xpressus.emsmtp.com>
|
||||||
|
Delivered-To: alice@example.org
|
||||||
|
To: alice@example.org
|
||||||
|
Subject: Vorteile sind zum Teilen da!
|
||||||
|
X-Mailer: class SMTPMail
|
||||||
|
From: "=?ISO-8859-1?Q?=D6AMTC?=" <clubinfo@donotreply.oeamtc.at>
|
||||||
|
MIME-Version: 1.0
|
||||||
|
List-Id: 134722648 <=?ISO-8859-1?Q?=D6AMTC?=>
|
||||||
|
List-Unsubscribe: <mailto:list-unsubscribe+xxx@emarsys.net>, <https://list-unsubscribe.eservice.emarsys.net/api/unsubscribe/xxx>
|
||||||
|
List-Unsubscribe-Post: List-Unsubscribe=One-Click
|
||||||
|
Content-Type: multipart/alternative;
|
||||||
|
boundary="--=_---NextPart--=_-wFcVesztLV"
|
||||||
|
Message-ID: <foobarbaz@pmta41019.emsmtp.com>
|
||||||
|
Date: Wed, 20 Mar 2024 10:00:01 +0100
|
||||||
|
|
||||||
|
|
||||||
|
----=_---NextPart--=_-wFcVesztLV
|
||||||
|
Content-Type: text/plain; charset=iso-8859-1
|
||||||
|
Content-transfer-encoding: quoted-printable
|
||||||
|
|
||||||
|
Plain text spam
|
||||||
|
|
||||||
|
----=_---NextPart--=_-wFcVesztLV
|
||||||
|
Content-Type: text/html; charset=iso-8859-1
|
||||||
|
Content-transfer-encoding: quoted-printable
|
||||||
|
|
||||||
|
HTML SPAM
|
||||||
|
----=_---NextPart--=_-wFcVesztLV--
|
||||||
Reference in New Issue
Block a user