mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
close #5161  --------- Co-authored-by: bjoern <r10s@b44t.com>
This commit is contained in:
@@ -345,6 +345,7 @@ pub enum SystemMessageType {
|
|||||||
SecurejoinMessage,
|
SecurejoinMessage,
|
||||||
LocationStreamingEnabled,
|
LocationStreamingEnabled,
|
||||||
LocationOnly,
|
LocationOnly,
|
||||||
|
InvalidUnencryptedMail,
|
||||||
|
|
||||||
/// Chat ephemeral message timer is changed.
|
/// Chat ephemeral message timer is changed.
|
||||||
EphemeralTimerChanged,
|
EphemeralTimerChanged,
|
||||||
@@ -385,6 +386,7 @@ impl From<deltachat::mimeparser::SystemMessage> for SystemMessageType {
|
|||||||
SystemMessage::MultiDeviceSync => SystemMessageType::MultiDeviceSync,
|
SystemMessage::MultiDeviceSync => SystemMessageType::MultiDeviceSync,
|
||||||
SystemMessage::WebxdcStatusUpdate => SystemMessageType::WebxdcStatusUpdate,
|
SystemMessage::WebxdcStatusUpdate => SystemMessageType::WebxdcStatusUpdate,
|
||||||
SystemMessage::WebxdcInfoMessage => SystemMessageType::WebxdcInfoMessage,
|
SystemMessage::WebxdcInfoMessage => SystemMessageType::WebxdcInfoMessage,
|
||||||
|
SystemMessage::InvalidUnencryptedMail => SystemMessageType::InvalidUnencryptedMail,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,10 @@ pub enum SystemMessage {
|
|||||||
/// "%1$s sent a message from another device."
|
/// "%1$s sent a message from another device."
|
||||||
ChatProtectionDisabled = 12,
|
ChatProtectionDisabled = 12,
|
||||||
|
|
||||||
|
/// Message can't be sent because of `Invalid unencrypted mail to <>`
|
||||||
|
/// which is sent by chatmail servers.
|
||||||
|
InvalidUnencryptedMail = 13,
|
||||||
|
|
||||||
/// Self-sent-message that contains only json used for multi-device-sync;
|
/// Self-sent-message that contains only json used for multi-device-sync;
|
||||||
/// if possible, we attach that to other messages as for locations.
|
/// if possible, we attach that to other messages as for locations.
|
||||||
MultiDeviceSync = 20,
|
MultiDeviceSync = 20,
|
||||||
|
|||||||
43
src/smtp.rs
43
src/smtp.rs
@@ -10,6 +10,7 @@ use async_smtp::{self as smtp, EmailAddress, SmtpTransport};
|
|||||||
use tokio::io::BufStream;
|
use tokio::io::BufStream;
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::chat::{add_info_msg_with_cmd, ChatId};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::contact::{Contact, ContactId};
|
use crate::contact::{Contact, ContactId};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
@@ -26,6 +27,7 @@ use crate::provider::Socket;
|
|||||||
use crate::scheduler::connectivity::ConnectivityStore;
|
use crate::scheduler::connectivity::ConnectivityStore;
|
||||||
use crate::socks::Socks5Config;
|
use crate::socks::Socks5Config;
|
||||||
use crate::sql;
|
use crate::sql;
|
||||||
|
use crate::stock_str::unencrypted_email;
|
||||||
|
|
||||||
/// SMTP connection, write and read timeout.
|
/// SMTP connection, write and read timeout.
|
||||||
const SMTP_TIMEOUT: Duration = Duration::from_secs(60);
|
const SMTP_TIMEOUT: Duration = Duration::from_secs(60);
|
||||||
@@ -584,7 +586,46 @@ pub(crate) async fn send_msg_to_smtp(
|
|||||||
|
|
||||||
match status {
|
match status {
|
||||||
SendResult::Retry => {}
|
SendResult::Retry => {}
|
||||||
SendResult::Success | SendResult::Failure(_) => {
|
SendResult::Success => {
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.execute("DELETE FROM smtp WHERE id=?", (rowid,))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
SendResult::Failure(ref err) => {
|
||||||
|
if err.to_string().contains("Invalid unencrypted mail") {
|
||||||
|
let res = context
|
||||||
|
.sql
|
||||||
|
.query_row_optional(
|
||||||
|
"SELECT chat_id, timestamp FROM msgs WHERE id=?;",
|
||||||
|
(msg_id,),
|
||||||
|
|row| Ok((row.get::<_, ChatId>(0)?, row.get::<_, i64>(1)?)),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if let Some((chat_id, timestamp_sort)) = res {
|
||||||
|
let addr = context.get_config(Config::ConfiguredAddr).await?;
|
||||||
|
let text = unencrypted_email(
|
||||||
|
context,
|
||||||
|
addr.unwrap_or_default()
|
||||||
|
.split('@')
|
||||||
|
.nth(1)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
add_info_msg_with_cmd(
|
||||||
|
context,
|
||||||
|
chat_id,
|
||||||
|
&text,
|
||||||
|
crate::mimeparser::SystemMessage::InvalidUnencryptedMail,
|
||||||
|
timestamp_sort,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
};
|
||||||
|
}
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute("DELETE FROM smtp WHERE id=?", (rowid,))
|
.execute("DELETE FROM smtp WHERE id=?", (rowid,))
|
||||||
|
|||||||
@@ -419,6 +419,11 @@ pub enum StockMessage {
|
|||||||
|
|
||||||
#[strum(props(fallback = "Member %1$s added."))]
|
#[strum(props(fallback = "Member %1$s added."))]
|
||||||
MsgAddMember = 173,
|
MsgAddMember = 173,
|
||||||
|
|
||||||
|
#[strum(props(
|
||||||
|
fallback = "⚠️ Your email provider %1$s requires end-to-end encryption which is not setup yet."
|
||||||
|
))]
|
||||||
|
InvalidUnencryptedMail = 174,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StockMessage {
|
impl StockMessage {
|
||||||
@@ -1285,6 +1290,13 @@ pub(crate) async fn aeap_addr_changed(
|
|||||||
.replace3(new_addr)
|
.replace3(new_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stock string: `⚠️ Your email provider %1$s requires end-to-end encryption which is not setup yet. Tap to learn more.`.
|
||||||
|
pub(crate) async fn unencrypted_email(context: &Context, provider: &str) -> String {
|
||||||
|
translated(context, StockMessage::InvalidUnencryptedMail)
|
||||||
|
.await
|
||||||
|
.replace1(provider)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn aeap_explanation_and_link(
|
pub(crate) async fn aeap_explanation_and_link(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
old_addr: &str,
|
old_addr: &str,
|
||||||
|
|||||||
Reference in New Issue
Block a user