mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
fix: Still send MDNs from bots by default
Fixup for 5ce44ade1. It is good that read receipts are sent by bots to see the bot received the
message. Thanks to @adbenitez for pointing this out.
This commit is contained in:
@@ -514,14 +514,22 @@ impl Context {
|
|||||||
&& !self.get_config_bool(Config::Bot).await?)
|
&& !self.get_config_bool(Config::Bot).await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether MDNs should be requested and sent.
|
/// Returns whether MDNs should be requested.
|
||||||
pub(crate) async fn mdns_enabled(&self) -> Result<bool> {
|
pub(crate) async fn should_request_mdns(&self) -> Result<bool> {
|
||||||
match self.get_config_bool_opt(Config::MdnsEnabled).await? {
|
match self.get_config_bool_opt(Config::MdnsEnabled).await? {
|
||||||
Some(val) => Ok(val),
|
Some(val) => Ok(val),
|
||||||
None => Ok(!self.get_config_bool(Config::Bot).await?),
|
None => Ok(!self.get_config_bool(Config::Bot).await?),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether MDNs should be sent.
|
||||||
|
pub(crate) async fn should_send_mdns(&self) -> Result<bool> {
|
||||||
|
Ok(self
|
||||||
|
.get_config_bool_opt(Config::MdnsEnabled)
|
||||||
|
.await?
|
||||||
|
.unwrap_or(true))
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets configured "delete_server_after" value.
|
/// Gets configured "delete_server_after" value.
|
||||||
///
|
///
|
||||||
/// `None` means never delete the message, `Some(0)` means delete
|
/// `None` means never delete the message, `Some(0)` means delete
|
||||||
@@ -972,11 +980,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_mdns_enabled() -> Result<()> {
|
async fn test_mdns_default_behaviour() -> Result<()> {
|
||||||
let t = &TestContext::new_alice().await;
|
let t = &TestContext::new_alice().await;
|
||||||
assert!(t.mdns_enabled().await?);
|
assert!(t.should_request_mdns().await?);
|
||||||
|
assert!(t.should_send_mdns().await?);
|
||||||
t.set_config_bool(Config::Bot, true).await?;
|
t.set_config_bool(Config::Bot, true).await?;
|
||||||
assert!(!t.mdns_enabled().await?);
|
assert!(!t.should_request_mdns().await?);
|
||||||
|
assert!(t.should_send_mdns().await?);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1769,7 +1769,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
|
|||||||
if curr_blocked == Blocked::Not
|
if curr_blocked == Blocked::Not
|
||||||
&& curr_param.get_bool(Param::WantsMdn).unwrap_or_default()
|
&& curr_param.get_bool(Param::WantsMdn).unwrap_or_default()
|
||||||
&& curr_param.get_cmd() == SystemMessage::Unknown
|
&& curr_param.get_cmd() == SystemMessage::Unknown
|
||||||
&& context.mdns_enabled().await?
|
&& context.should_send_mdns().await?
|
||||||
{
|
{
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ impl MimeFactory {
|
|||||||
|
|
||||||
if !msg.is_system_message()
|
if !msg.is_system_message()
|
||||||
&& msg.param.get_int(Param::Reaction).unwrap_or_default() == 0
|
&& msg.param.get_int(Param::Reaction).unwrap_or_default() == 0
|
||||||
&& context.mdns_enabled().await?
|
&& context.should_request_mdns().await?
|
||||||
{
|
{
|
||||||
req_mdn = true;
|
req_mdn = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -631,7 +631,7 @@ async fn send_mdn_rfc724_mid(
|
|||||||
|
|
||||||
/// Tries to send a single MDN. Returns true if more MDNs should be sent.
|
/// Tries to send a single MDN. Returns true if more MDNs should be sent.
|
||||||
async fn send_mdn(context: &Context, smtp: &mut Smtp) -> Result<bool> {
|
async fn send_mdn(context: &Context, smtp: &mut Smtp) -> Result<bool> {
|
||||||
if !context.mdns_enabled().await? {
|
if !context.should_send_mdns().await? {
|
||||||
context.sql.execute("DELETE FROM smtp_mdns", []).await?;
|
context.sql.execute("DELETE FROM smtp_mdns", []).await?;
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user