mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
feat: remove show_emails config
This commit is contained in:
@@ -440,12 +440,6 @@ char* dc_get_blobdir (const dc_context_t* context);
|
|||||||
* spam folder and `sendbox_watch` will also still be respected
|
* spam folder and `sendbox_watch` will also still be respected
|
||||||
* if enabled.
|
* if enabled.
|
||||||
* 0=watch all folders normally (default)
|
* 0=watch all folders normally (default)
|
||||||
* - `show_emails` = DC_SHOW_EMAILS_OFF (0)=
|
|
||||||
* show direct replies to chats only,
|
|
||||||
* DC_SHOW_EMAILS_ACCEPTED_CONTACTS (1)=
|
|
||||||
* also show all mails of confirmed contacts,
|
|
||||||
* DC_SHOW_EMAILS_ALL (2)=
|
|
||||||
* also show mails of unconfirmed contacts (default).
|
|
||||||
* - `delete_device_after` = 0=do not delete messages from device automatically (default),
|
* - `delete_device_after` = 0=do not delete messages from device automatically (default),
|
||||||
* >=1=seconds, after which messages are deleted automatically from the device.
|
* >=1=seconds, after which messages are deleted automatically from the device.
|
||||||
* Messages in the "saved messages" chat (see dc_chat_is_self_talk()) are skipped.
|
* Messages in the "saved messages" chat (see dc_chat_is_self_talk()) are skipped.
|
||||||
@@ -454,8 +448,7 @@ char* dc_get_blobdir (const dc_context_t* context);
|
|||||||
* - `delete_server_after` = 0=do not delete messages from server automatically (default),
|
* - `delete_server_after` = 0=do not delete messages from server automatically (default),
|
||||||
* 1=delete messages directly after receiving from server, mvbox is skipped.
|
* 1=delete messages directly after receiving from server, mvbox is skipped.
|
||||||
* >1=seconds, after which messages are deleted automatically from the server, mvbox is used as defined.
|
* >1=seconds, after which messages are deleted automatically from the server, mvbox is used as defined.
|
||||||
* "Saved messages" are deleted from the server as well as
|
* "Saved messages" are deleted from the server as well as emails, the UI should clearly point that out.
|
||||||
* e-mails matching the `show_emails` settings above, the UI should clearly point that out.
|
|
||||||
* See also dc_estimate_deletion_cnt().
|
* See also dc_estimate_deletion_cnt().
|
||||||
* - `media_quality` = DC_MEDIA_QUALITY_BALANCED (0) =
|
* - `media_quality` = DC_MEDIA_QUALITY_BALANCED (0) =
|
||||||
* good outgoing images/videos/voice quality at reasonable sizes (default)
|
* good outgoing images/videos/voice quality at reasonable sizes (default)
|
||||||
@@ -1478,7 +1471,6 @@ dc_chatlist_t* dc_get_similar_chatlist (dc_context_t* context, uint32_t ch
|
|||||||
* @param from_server 1=Estimate deletion count for server, 0=Estimate deletion count for device
|
* @param from_server 1=Estimate deletion count for server, 0=Estimate deletion count for device
|
||||||
* @param seconds Count messages older than the given number of seconds.
|
* @param seconds Count messages older than the given number of seconds.
|
||||||
* @return Number of messages that are older than the given number of seconds.
|
* @return Number of messages that are older than the given number of seconds.
|
||||||
* This includes e-mails downloaded due to the `show_emails` option.
|
|
||||||
* Messages in the "saved messages" folder are not counted as they will not be deleted automatically.
|
* Messages in the "saved messages" folder are not counted as they will not be deleted automatically.
|
||||||
*/
|
*/
|
||||||
int dc_estimate_deletion_cnt (dc_context_t* context, int from_server, int64_t seconds);
|
int dc_estimate_deletion_cnt (dc_context_t* context, int from_server, int64_t seconds);
|
||||||
@@ -6712,14 +6704,6 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
#define DC_EVENT_DATA2_IS_STRING(e) ((e)==DC_EVENT_CONFIGURE_PROGRESS || (e)==DC_EVENT_IMEX_FILE_WRITTEN || ((e)>=100 && (e)<=499))
|
#define DC_EVENT_DATA2_IS_STRING(e) ((e)==DC_EVENT_CONFIGURE_PROGRESS || (e)==DC_EVENT_IMEX_FILE_WRITTEN || ((e)>=100 && (e)<=499))
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values for dc_get|set_config("show_emails")
|
|
||||||
*/
|
|
||||||
#define DC_SHOW_EMAILS_OFF 0
|
|
||||||
#define DC_SHOW_EMAILS_ACCEPTED_CONTACTS 1
|
|
||||||
#define DC_SHOW_EMAILS_ALL 2
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Values for dc_get|set_config("media_quality")
|
* Values for dc_get|set_config("media_quality")
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1895,12 +1895,6 @@ async fn test_classic_email_chat() -> Result<()> {
|
|||||||
let msgs = get_chat_msgs(&alice, chat_id).await?;
|
let msgs = get_chat_msgs(&alice, chat_id).await?;
|
||||||
assert_eq!(msgs.len(), 1);
|
assert_eq!(msgs.len(), 1);
|
||||||
|
|
||||||
// Alice disables receiving classic emails.
|
|
||||||
alice
|
|
||||||
.set_config(Config::ShowEmails, Some("0"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Already received classic email should still be in the chat.
|
// Already received classic email should still be in the chat.
|
||||||
assert_eq!(chat_id.get_fresh_msg_cnt(&alice).await?, 1);
|
assert_eq!(chat_id.get_fresh_msg_cnt(&alice).await?, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -167,10 +167,6 @@ pub enum Config {
|
|||||||
#[strum(props(default = "0"))]
|
#[strum(props(default = "0"))]
|
||||||
OnlyFetchMvbox,
|
OnlyFetchMvbox,
|
||||||
|
|
||||||
/// Whether to show classic emails or only chat messages.
|
|
||||||
#[strum(props(default = "2"))] // also change ShowEmails.default() on changes
|
|
||||||
ShowEmails,
|
|
||||||
|
|
||||||
/// Quality of the media files to send.
|
/// Quality of the media files to send.
|
||||||
#[strum(props(default = "0"))] // also change MediaQuality.default() on changes
|
#[strum(props(default = "0"))] // also change MediaQuality.default() on changes
|
||||||
MediaQuality,
|
MediaQuality,
|
||||||
@@ -464,7 +460,6 @@ impl Config {
|
|||||||
Self::Displayname
|
Self::Displayname
|
||||||
| Self::MdnsEnabled
|
| Self::MdnsEnabled
|
||||||
| Self::MvboxMove
|
| Self::MvboxMove
|
||||||
| Self::ShowEmails
|
|
||||||
| Self::Selfavatar
|
| Self::Selfavatar
|
||||||
| Self::Selfstatus,
|
| Self::Selfstatus,
|
||||||
)
|
)
|
||||||
@@ -711,12 +706,7 @@ impl Context {
|
|||||||
Self::check_config(key, value)?;
|
Self::check_config(key, value)?;
|
||||||
|
|
||||||
let n_transports = self.count_transports().await?;
|
let n_transports = self.count_transports().await?;
|
||||||
if n_transports > 1
|
if n_transports > 1 && matches!(key, Config::MvboxMove | Config::OnlyFetchMvbox) {
|
||||||
&& matches!(
|
|
||||||
key,
|
|
||||||
Config::MvboxMove | Config::OnlyFetchMvbox | Config::ShowEmails
|
|
||||||
)
|
|
||||||
{
|
|
||||||
bail!("Cannot reconfigure {key} when multiple transports are configured");
|
bail!("Cannot reconfigure {key} when multiple transports are configured");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,12 +165,10 @@ async fn test_sync() -> Result<()> {
|
|||||||
sync(&alice0, &alice1).await;
|
sync(&alice0, &alice1).await;
|
||||||
assert_eq!(alice1.get_config_bool(Config::MdnsEnabled).await?, false);
|
assert_eq!(alice1.get_config_bool(Config::MdnsEnabled).await?, false);
|
||||||
|
|
||||||
for key in [Config::ShowEmails, Config::MvboxMove] {
|
let val = alice0.get_config_bool(Config::MvboxMove).await?;
|
||||||
let val = alice0.get_config_bool(key).await?;
|
alice0.set_config_bool(Config::MvboxMove, !val).await?;
|
||||||
alice0.set_config_bool(key, !val).await?;
|
sync(&alice0, &alice1).await;
|
||||||
sync(&alice0, &alice1).await;
|
assert_eq!(alice1.get_config_bool(Config::MvboxMove).await?, !val);
|
||||||
assert_eq!(alice1.get_config_bool(key).await?, !val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// `Config::SyncMsgs` mustn't be synced.
|
// `Config::SyncMsgs` mustn't be synced.
|
||||||
alice0.set_config_bool(Config::SyncMsgs, false).await?;
|
alice0.set_config_bool(Config::SyncMsgs, false).await?;
|
||||||
|
|||||||
@@ -282,11 +282,6 @@ impl Context {
|
|||||||
"To use additional relays, disable the legacy option \"Settings / Advanced / Only Fetch from DeltaChat Folder\"."
|
"To use additional relays, disable the legacy option \"Settings / Advanced / Only Fetch from DeltaChat Folder\"."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if self.get_config(Config::ShowEmails).await?.as_deref() != Some("2") {
|
|
||||||
bail!(
|
|
||||||
"To use additional relays, set the legacy option \"Settings / Advanced / Show Classic Emails\" to \"All\"."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self
|
if self
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
@@ -36,17 +36,6 @@ pub enum Blocked {
|
|||||||
Request = 2,
|
Request = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
|
||||||
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql,
|
|
||||||
)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum ShowEmails {
|
|
||||||
Off = 0,
|
|
||||||
AcceptedContacts = 1,
|
|
||||||
#[default] // also change Config.ShowEmails props(default) on changes
|
|
||||||
All = 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql,
|
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql,
|
||||||
)]
|
)]
|
||||||
@@ -277,18 +266,6 @@ mod tests {
|
|||||||
assert_eq!(Chattype::OutBroadcast, Chattype::from_i32(160).unwrap());
|
assert_eq!(Chattype::OutBroadcast, Chattype::from_i32(160).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_showemails_values() {
|
|
||||||
// values may be written to disk and must not change
|
|
||||||
assert_eq!(ShowEmails::All, ShowEmails::default());
|
|
||||||
assert_eq!(ShowEmails::Off, ShowEmails::from_i32(0).unwrap());
|
|
||||||
assert_eq!(
|
|
||||||
ShowEmails::AcceptedContacts,
|
|
||||||
ShowEmails::from_i32(1).unwrap()
|
|
||||||
);
|
|
||||||
assert_eq!(ShowEmails::All, ShowEmails::from_i32(2).unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_blocked_values() {
|
fn test_blocked_values() {
|
||||||
// values may be written to disk and must not change
|
// values may be written to disk and must not change
|
||||||
|
|||||||
@@ -945,10 +945,6 @@ impl Context {
|
|||||||
.await?
|
.await?
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
res.insert(
|
|
||||||
"show_emails",
|
|
||||||
self.get_config_int(Config::ShowEmails).await?.to_string(),
|
|
||||||
);
|
|
||||||
res.insert(
|
res.insert(
|
||||||
"download_limit",
|
"download_limit",
|
||||||
self.get_config_int(Config::DownloadLimit)
|
self.get_config_int(Config::DownloadLimit)
|
||||||
|
|||||||
11
src/html.rs
11
src/html.rs
@@ -281,7 +281,6 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::chat;
|
use crate::chat;
|
||||||
use crate::chat::{forward_msgs, save_msgs};
|
use crate::chat::{forward_msgs, save_msgs};
|
||||||
use crate::config::Config;
|
|
||||||
use crate::contact::ContactId;
|
use crate::contact::ContactId;
|
||||||
use crate::message::{MessengerMessage, Viewtype};
|
use crate::message::{MessengerMessage, Viewtype};
|
||||||
use crate::receive_imf::receive_imf;
|
use crate::receive_imf::receive_imf;
|
||||||
@@ -522,13 +521,7 @@ test some special html-characters as < > and & but also " and &#x
|
|||||||
async fn test_html_forwarding_encrypted() {
|
async fn test_html_forwarding_encrypted() {
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
// Alice receives a non-delta html-message
|
// Alice receives a non-delta html-message
|
||||||
// (`ShowEmails=AcceptedContacts` lets Alice actually receive non-delta messages for known
|
|
||||||
// contacts, the contact is marked as known by creating a chat using `chat_with_contact()`)
|
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
alice
|
|
||||||
.set_config(Config::ShowEmails, Some("1"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let chat = alice
|
let chat = alice
|
||||||
.create_chat_with_contact("", "sender@testrun.org")
|
.create_chat_with_contact("", "sender@testrun.org")
|
||||||
.await;
|
.await;
|
||||||
@@ -546,10 +539,6 @@ test some special html-characters as < > and & but also " and &#x
|
|||||||
|
|
||||||
// receive the message on another device
|
// receive the message on another device
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
alice
|
|
||||||
.set_config(Config::ShowEmails, Some("0"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let msg = alice.recv_msg(&msg).await;
|
let msg = alice.recv_msg(&msg).await;
|
||||||
assert_eq!(msg.chat_id, alice.get_self_chat().await.id);
|
assert_eq!(msg.chat_id, alice.get_self_chat().await.id);
|
||||||
assert_eq!(msg.get_from_id(), ContactId::SELF);
|
assert_eq!(msg.get_from_id(), ContactId::SELF);
|
||||||
|
|||||||
29
src/imap.rs
29
src/imap.rs
@@ -19,7 +19,6 @@ use async_imap::types::{Fetch, Flag, Name, NameAttribute, UnsolicitedResponse};
|
|||||||
use deltachat_contact_tools::ContactAddress;
|
use deltachat_contact_tools::ContactAddress;
|
||||||
use futures::{FutureExt as _, TryStreamExt};
|
use futures::{FutureExt as _, TryStreamExt};
|
||||||
use futures_lite::FutureExt;
|
use futures_lite::FutureExt;
|
||||||
use num_traits::FromPrimitive;
|
|
||||||
use ratelimit::Ratelimit;
|
use ratelimit::Ratelimit;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ use crate::calls::{create_fallback_ice_servers, create_ice_servers_from_metadata
|
|||||||
use crate::chat::{self, ChatId, ChatIdBlocked, add_device_msg};
|
use crate::chat::{self, ChatId, ChatIdBlocked, add_device_msg};
|
||||||
use crate::chatlist_events;
|
use crate::chatlist_events;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::{self, Blocked, Chattype, DC_VERSION_STR, ShowEmails};
|
use crate::constants::{self, Blocked, Chattype, DC_VERSION_STR};
|
||||||
use crate::contact::{Contact, ContactId, Modifier, Origin};
|
use crate::contact::{Contact, ContactId, Modifier, Origin};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::events::EventType;
|
use crate::events::EventType;
|
||||||
@@ -2317,7 +2316,7 @@ pub(crate) async fn prefetch_should_download(
|
|||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
None => return Ok(false),
|
None => return Ok(false),
|
||||||
};
|
};
|
||||||
let (_from_id, blocked_contact, origin) =
|
let (_from_id, blocked_contact, _origin) =
|
||||||
match from_field_to_contact_id(context, &from, None, true, true).await? {
|
match from_field_to_contact_id(context, &from, None, true, true).await? {
|
||||||
Some(res) => res,
|
Some(res) => res,
|
||||||
None => return Ok(false),
|
None => return Ok(false),
|
||||||
@@ -2330,29 +2329,7 @@ pub(crate) async fn prefetch_should_download(
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_chat_message = headers.get_header_value(HeaderDef::ChatVersion).is_some();
|
let should_download = !blocked_contact || maybe_ndn;
|
||||||
let accepted_contact = origin.is_known();
|
|
||||||
let is_reply_to_chat_message = get_prefetch_parent_message(context, headers)
|
|
||||||
.await?
|
|
||||||
.map(|parent| match parent.is_dc_message {
|
|
||||||
MessengerMessage::No => false,
|
|
||||||
MessengerMessage::Yes | MessengerMessage::Reply => true,
|
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let show_emails =
|
|
||||||
ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?).unwrap_or_default();
|
|
||||||
|
|
||||||
let show = is_autocrypt_setup_message
|
|
||||||
|| match show_emails {
|
|
||||||
ShowEmails::Off => is_chat_message || is_reply_to_chat_message,
|
|
||||||
ShowEmails::AcceptedContacts => {
|
|
||||||
is_chat_message || is_reply_to_chat_message || accepted_contact
|
|
||||||
}
|
|
||||||
ShowEmails::All => true,
|
|
||||||
};
|
|
||||||
|
|
||||||
let should_download = (show && !blocked_contact) || maybe_ndn;
|
|
||||||
Ok(should_download)
|
Ok(should_download)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2018,7 +2018,6 @@ pub async fn get_request_msg_cnt(context: &Context) -> usize {
|
|||||||
/// Count messages older than the given number of `seconds`.
|
/// Count messages older than the given number of `seconds`.
|
||||||
///
|
///
|
||||||
/// Returns the number of messages that are older than the given number of seconds.
|
/// Returns the number of messages that are older than the given number of seconds.
|
||||||
/// This includes e-mails downloaded due to the `show_emails` option.
|
|
||||||
/// Messages in the "saved messages" folder are not counted as they will not be deleted automatically.
|
/// Messages in the "saved messages" folder are not counted as they will not be deleted automatically.
|
||||||
pub async fn estimate_deletion_cnt(
|
pub async fn estimate_deletion_cnt(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
|
|||||||
@@ -503,11 +503,6 @@ async fn msg_to_subject_str_inner(
|
|||||||
|
|
||||||
// Creates a `Message` that replies "Hi" to the incoming email in `imf_raw`.
|
// Creates a `Message` that replies "Hi" to the incoming email in `imf_raw`.
|
||||||
async fn incoming_msg_to_reply_msg(imf_raw: &[u8], context: &Context) -> Message {
|
async fn incoming_msg_to_reply_msg(imf_raw: &[u8], context: &Context) -> Message {
|
||||||
context
|
|
||||||
.set_config(Config::ShowEmails, Some("2"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
receive_imf(context, imf_raw, false).await.unwrap();
|
receive_imf(context, imf_raw, false).await.unwrap();
|
||||||
|
|
||||||
let chats = Chatlist::try_load(context, 0, None, None).await.unwrap();
|
let chats = Chatlist::try_load(context, 0, None, None).await.unwrap();
|
||||||
|
|||||||
@@ -638,16 +638,10 @@ static P_HERMES_RADIO: Provider = Provider {
|
|||||||
strict_tls: false,
|
strict_tls: false,
|
||||||
..ProviderOptions::new()
|
..ProviderOptions::new()
|
||||||
},
|
},
|
||||||
config_defaults: Some(&[
|
config_defaults: Some(&[ConfigDefault {
|
||||||
ConfigDefault {
|
key: Config::MdnsEnabled,
|
||||||
key: Config::MdnsEnabled,
|
value: "0",
|
||||||
value: "0",
|
}]),
|
||||||
},
|
|
||||||
ConfigDefault {
|
|
||||||
key: Config::ShowEmails,
|
|
||||||
value: "2",
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
oauth2_authorizer: None,
|
oauth2_authorizer: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ use deltachat_contact_tools::{
|
|||||||
};
|
};
|
||||||
use iroh_gossip::proto::TopicId;
|
use iroh_gossip::proto::TopicId;
|
||||||
use mailparse::SingleInfo;
|
use mailparse::SingleInfo;
|
||||||
use num_traits::FromPrimitive;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, save_broadcast_secret};
|
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, save_broadcast_secret};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::{self, Blocked, Chattype, DC_CHAT_ID_TRASH, EDITED_PREFIX, ShowEmails};
|
use crate::constants::{self, Blocked, Chattype, DC_CHAT_ID_TRASH, EDITED_PREFIX};
|
||||||
use crate::contact::{self, Contact, ContactId, Origin, mark_contact_id_as_verified};
|
use crate::contact::{self, Contact, ContactId, Origin, mark_contact_id_as_verified};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::debug_logging::maybe_set_logging_xdc_inner;
|
use crate::debug_logging::maybe_set_logging_xdc_inner;
|
||||||
@@ -739,21 +738,8 @@ pub(crate) async fn receive_imf_inner(
|
|||||||
MessengerMessage::No
|
MessengerMessage::No
|
||||||
};
|
};
|
||||||
|
|
||||||
let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?)
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let allow_creation = if mime_parser.decrypting_failed {
|
let allow_creation = if mime_parser.decrypting_failed {
|
||||||
false
|
false
|
||||||
} else if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage
|
|
||||||
&& is_dc_message == MessengerMessage::No
|
|
||||||
&& !context.get_config_bool(Config::IsChatmail).await?
|
|
||||||
{
|
|
||||||
// the message is a classic email in a classic profile
|
|
||||||
// (in chatmail profiles, we always show all messages, because shared dc-mua usage is not supported)
|
|
||||||
match show_emails {
|
|
||||||
ShowEmails::Off | ShowEmails::AcceptedContacts => false,
|
|
||||||
ShowEmails::All => true,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
!mime_parser.parts.iter().all(|part| part.is_reaction)
|
!mime_parser.parts.iter().all(|part| part.is_reaction)
|
||||||
};
|
};
|
||||||
@@ -1177,20 +1163,6 @@ async fn decide_chat_assignment(
|
|||||||
}
|
}
|
||||||
info!(context, "Outgoing undecryptable message (TRASH).");
|
info!(context, "Outgoing undecryptable message (TRASH).");
|
||||||
true
|
true
|
||||||
} else if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage
|
|
||||||
&& !mime_parser.has_chat_version()
|
|
||||||
&& parent_message
|
|
||||||
.as_ref()
|
|
||||||
.is_none_or(|p| p.is_dc_message == MessengerMessage::No)
|
|
||||||
&& !context.get_config_bool(Config::IsChatmail).await?
|
|
||||||
&& ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?)
|
|
||||||
.unwrap_or_default()
|
|
||||||
== ShowEmails::Off
|
|
||||||
{
|
|
||||||
info!(context, "Classical email not shown (TRASH).");
|
|
||||||
// the message is a classic email in a classic profile
|
|
||||||
// (in chatmail profiles, we always show all messages, because shared dc-mua usage is not supported)
|
|
||||||
true
|
|
||||||
} else if mime_parser
|
} else if mime_parser
|
||||||
.get_header(HeaderDef::XMozillaDraftInfo)
|
.get_header(HeaderDef::XMozillaDraftInfo)
|
||||||
.is_some()
|
.is_some()
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ static GRP_MAIL: &[u8] =
|
|||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_adhoc_group_show_chats_only() {
|
async fn test_adhoc_group_show_chats_only() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t.set_config(Config::ShowEmails, Some("0")).await.unwrap();
|
|
||||||
|
|
||||||
let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap();
|
let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap();
|
||||||
assert_eq!(chats.len(), 0);
|
assert_eq!(chats.len(), 0);
|
||||||
@@ -102,7 +101,6 @@ async fn test_adhoc_group_show_chats_only() {
|
|||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_adhoc_group_show_accepted_contact_unknown() {
|
async fn test_adhoc_group_show_accepted_contact_unknown() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t.set_config(Config::ShowEmails, Some("1")).await.unwrap();
|
|
||||||
receive_imf(&t, GRP_MAIL, false).await.unwrap();
|
receive_imf(&t, GRP_MAIL, false).await.unwrap();
|
||||||
|
|
||||||
// adhoc-group with unknown contacts with show_emails=accepted is ignored for unknown contacts
|
// adhoc-group with unknown contacts with show_emails=accepted is ignored for unknown contacts
|
||||||
@@ -115,11 +113,6 @@ async fn test_adhoc_group_outgoing_show_accepted_contact_unaccepted() -> Result<
|
|||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
let bob = &tcm.bob().await;
|
let bob = &tcm.bob().await;
|
||||||
bob.set_config(
|
|
||||||
Config::ShowEmails,
|
|
||||||
Some(&ShowEmails::AcceptedContacts.to_string()),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
tcm.send_recv(alice, bob, "hi").await;
|
tcm.send_recv(alice, bob, "hi").await;
|
||||||
receive_imf(
|
receive_imf(
|
||||||
bob,
|
bob,
|
||||||
@@ -142,7 +135,6 @@ async fn test_adhoc_group_outgoing_show_accepted_contact_unaccepted() -> Result<
|
|||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_adhoc_group_show_accepted_contact_known() {
|
async fn test_adhoc_group_show_accepted_contact_known() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t.set_config(Config::ShowEmails, Some("1")).await.unwrap();
|
|
||||||
Contact::create(&t, "Bob", "bob@example.com").await.unwrap();
|
Contact::create(&t, "Bob", "bob@example.com").await.unwrap();
|
||||||
receive_imf(&t, GRP_MAIL, false).await.unwrap();
|
receive_imf(&t, GRP_MAIL, false).await.unwrap();
|
||||||
|
|
||||||
@@ -155,7 +147,6 @@ async fn test_adhoc_group_show_accepted_contact_known() {
|
|||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_adhoc_group_show_accepted_contact_accepted() {
|
async fn test_adhoc_group_show_accepted_contact_accepted() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t.set_config(Config::ShowEmails, Some("1")).await.unwrap();
|
|
||||||
|
|
||||||
// accept Bob by accepting a delta-message from Bob
|
// accept Bob by accepting a delta-message from Bob
|
||||||
receive_imf(&t, MSGRMSG, false).await.unwrap();
|
receive_imf(&t, MSGRMSG, false).await.unwrap();
|
||||||
@@ -191,7 +182,6 @@ async fn test_adhoc_group_show_accepted_contact_accepted() {
|
|||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_adhoc_group_show_all() {
|
async fn test_adhoc_group_show_all() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
assert_eq!(t.get_config_int(Config::ShowEmails).await.unwrap(), 2);
|
|
||||||
receive_imf(&t, GRP_MAIL, false).await.unwrap();
|
receive_imf(&t, GRP_MAIL, false).await.unwrap();
|
||||||
|
|
||||||
// adhoc-group with unknown contacts with show_emails=all will show up in a single chat
|
// adhoc-group with unknown contacts with show_emails=all will show up in a single chat
|
||||||
@@ -817,10 +807,6 @@ async fn test_concat_multiple_ndns() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message {
|
async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message {
|
||||||
context
|
|
||||||
.set_config(Config::ShowEmails, Some("2"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
receive_imf(context, imf_raw, false).await.unwrap();
|
receive_imf(context, imf_raw, false).await.unwrap();
|
||||||
let chats = Chatlist::try_load(context, 0, None, None).await.unwrap();
|
let chats = Chatlist::try_load(context, 0, None, None).await.unwrap();
|
||||||
let msg_id = chats.get_msg_id(0).unwrap().unwrap();
|
let msg_id = chats.get_msg_id(0).unwrap().unwrap();
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use rusqlite::OptionalExtension;
|
|||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::configure::EnteredLoginParam;
|
use crate::configure::EnteredLoginParam;
|
||||||
use crate::constants::ShowEmails;
|
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::key::DcKey;
|
use crate::key::DcKey;
|
||||||
use crate::log::warn;
|
use crate::log::warn;
|
||||||
@@ -226,8 +225,7 @@ ALTER TABLE msgs ADD COLUMN mime_references TEXT;"#,
|
|||||||
// keep this default and use DC_SHOW_EMAILS_NO
|
// keep this default and use DC_SHOW_EMAILS_NO
|
||||||
// only for new installations
|
// only for new installations
|
||||||
if exists_before_update {
|
if exists_before_update {
|
||||||
sql.set_raw_config_int("show_emails", ShowEmails::All as i32)
|
sql.set_raw_config_int("show_emails", 2).await?;
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
sql.set_db_version(50).await?;
|
sql.set_db_version(50).await?;
|
||||||
}
|
}
|
||||||
@@ -708,8 +706,7 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid);
|
|||||||
}
|
}
|
||||||
if dbversion < 98 {
|
if dbversion < 98 {
|
||||||
if exists_before_update && sql.get_raw_config_int("show_emails").await?.is_none() {
|
if exists_before_update && sql.get_raw_config_int("show_emails").await?.is_none() {
|
||||||
sql.set_raw_config_int("show_emails", ShowEmails::Off as i32)
|
sql.set_raw_config_int("show_emails", 0).await?;
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
sql.set_db_version(98).await?;
|
sql.set_db_version(98).await?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -779,8 +779,7 @@ impl TestContext {
|
|||||||
let chat_msgs = chat::get_chat_msgs(self, received.chat_id).await.unwrap();
|
let chat_msgs = chat::get_chat_msgs(self, received.chat_id).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
chat_msgs.contains(&ChatItem::Message { msg_id: msg.id }),
|
chat_msgs.contains(&ChatItem::Message { msg_id: msg.id }),
|
||||||
"received message is not shown in chat, maybe it's hidden (you may have \
|
"received message is not shown in chat, maybe it's hidden"
|
||||||
to call set_config(Config::ShowEmails, Some(\"2\")).await)"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
msg
|
msg
|
||||||
|
|||||||
Reference in New Issue
Block a user