mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Use the message text as the initial subject
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
- Use message text as the initial subject for 1:1 contacts. #4036
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
|
|||||||
3
spec.md
3
spec.md
@@ -38,9 +38,6 @@ by the [Protected Headers](https://tools.ietf.org/id/draft-autocrypt-lamps-prote
|
|||||||
# Outgoing messages
|
# Outgoing messages
|
||||||
|
|
||||||
Messengers MUST add a `Chat-Version: 1.0` header to outgoing messages.
|
Messengers MUST add a `Chat-Version: 1.0` header to outgoing messages.
|
||||||
For filtering and smart appearance of the messages in normal MUAs,
|
|
||||||
the `Subject` header SHOULD be `Message from <sender name>`.
|
|
||||||
Replies to messages MAY follow the typical `Re:`-format.
|
|
||||||
|
|
||||||
The body MAY contain text which MUST have the content type `text/plain`
|
The body MAY contain text which MUST have the content type `text/plain`
|
||||||
or `mulipart/alternative` containing `text/plain`.
|
or `mulipart/alternative` containing `text/plain`.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use crate::stock_str;
|
|||||||
use crate::tools::IsNoneOrEmpty;
|
use crate::tools::IsNoneOrEmpty;
|
||||||
use crate::tools::{
|
use crate::tools::{
|
||||||
create_outgoing_rfc724_mid, create_smeared_timestamp, get_filebytes, remove_subject_prefix,
|
create_outgoing_rfc724_mid, create_smeared_timestamp, get_filebytes, remove_subject_prefix,
|
||||||
time,
|
time, truncate,
|
||||||
};
|
};
|
||||||
|
|
||||||
// attachments of 25 mb brutto should work on the majority of providers
|
// attachments of 25 mb brutto should work on the majority of providers
|
||||||
@@ -435,11 +435,7 @@ impl<'a> MimeFactory<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let self_name = &match context.get_config(Config::Displayname).await? {
|
truncate(self.msg.text.as_deref().unwrap_or_default().trim(), 40).to_string()
|
||||||
Some(name) => name,
|
|
||||||
None => context.get_config(Config::Addr).await?.unwrap_or_default(),
|
|
||||||
};
|
|
||||||
stock_str::subject_for_new_contact(context, self_name).await
|
|
||||||
}
|
}
|
||||||
Loaded::Mdn { .. } => stock_str::read_rcpt(context).await,
|
Loaded::Mdn { .. } => stock_str::read_rcpt(context).await,
|
||||||
};
|
};
|
||||||
@@ -1669,13 +1665,13 @@ mod tests {
|
|||||||
// 3. Send the first message to a new contact
|
// 3. Send the first message to a new contact
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
|
|
||||||
assert_eq!(first_subject_str(t).await, "Message from alice@example.org");
|
assert_eq!(first_subject_str(t).await, "Hi");
|
||||||
|
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t.set_config(Config::Displayname, Some("Alice"))
|
t.set_config(Config::Displayname, Some("Alice"))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(first_subject_str(t).await, "Message from Alice");
|
assert_eq!(first_subject_str(t).await, "Hi");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
|||||||
@@ -868,14 +868,6 @@ pub(crate) async fn unknown_sender_for_chat(context: &Context) -> String {
|
|||||||
translated(context, StockMessage::UnknownSenderForChat).await
|
translated(context, StockMessage::UnknownSenderForChat).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stock string: `Message from %1$s`.
|
|
||||||
// TODO: This can compute `self_name` itself instead of asking the caller to do this.
|
|
||||||
pub(crate) async fn subject_for_new_contact(context: &Context, self_name: &str) -> String {
|
|
||||||
translated(context, StockMessage::SubjectForNewContact)
|
|
||||||
.await
|
|
||||||
.replace1(self_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stock string: `Failed to send message to %1$s.`.
|
/// Stock string: `Failed to send message to %1$s.`.
|
||||||
pub(crate) async fn failed_sending_to(context: &Context, name: &str) -> String {
|
pub(crate) async fn failed_sending_to(context: &Context, name: &str) -> String {
|
||||||
translated(context, StockMessage::FailedSendingTo)
|
translated(context, StockMessage::FailedSendingTo)
|
||||||
|
|||||||
Reference in New Issue
Block a user