api!: deprecate DC_SHOW_EMAILS_ACCEPTED_CONTACTS

This commit is contained in:
link2xt
2025-04-16 00:32:35 +00:00
parent b0508e661a
commit 37462b3801
7 changed files with 17 additions and 25 deletions

View File

@@ -436,10 +436,10 @@ char* dc_get_blobdir (const dc_context_t* context);
* 0=watch all folders normally (default) * 0=watch all folders normally (default)
* - `show_emails` = DC_SHOW_EMAILS_OFF (0)= * - `show_emails` = DC_SHOW_EMAILS_OFF (0)=
* show direct replies to chats only, * show direct replies to chats only,
* DC_SHOW_EMAILS_ACCEPTED_CONTACTS (1)= * DC_SHOW_EMAILS_ALL1 (1)=
* also show all mails of confirmed contacts, * deprecated, same as DC_SHOW_EMAILS_ALL,
* DC_SHOW_EMAILS_ALL (2)= * DC_SHOW_EMAILS_ALL (2)=
* also show mails of unconfirmed contacts (default). * show all mails (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.
@@ -6582,7 +6582,7 @@ void dc_event_unref(dc_event_t* event);
* Values for dc_get|set_config("show_emails") * Values for dc_get|set_config("show_emails")
*/ */
#define DC_SHOW_EMAILS_OFF 0 #define DC_SHOW_EMAILS_OFF 0
#define DC_SHOW_EMAILS_ACCEPTED_CONTACTS 1 #define DC_SHOW_EMAILS_ALL1 1
#define DC_SHOW_EMAILS_ALL 2 #define DC_SHOW_EMAILS_ALL 2

View File

@@ -234,7 +234,6 @@ class ShowEmails(IntEnum):
"""Show emails mode.""" """Show emails mode."""
OFF = 0 OFF = 0
ACCEPTED_CONTACTS = 1
ALL = 2 ALL = 2

View File

@@ -45,8 +45,12 @@ pub enum Blocked {
#[repr(u8)] #[repr(u8)]
pub enum ShowEmails { pub enum ShowEmails {
Off = 0, Off = 0,
AcceptedContacts = 1,
#[default] // also change Config.ShowEmails props(default) on changes /// Deprecated 2025-04-16, same as All.
All1 = 1,
// also change Config.ShowEmails props(default) on changes
#[default]
All = 2, All = 2,
} }
@@ -253,10 +257,7 @@ mod tests {
// values may be written to disk and must not change // values may be written to disk and must not change
assert_eq!(ShowEmails::All, ShowEmails::default()); assert_eq!(ShowEmails::All, ShowEmails::default());
assert_eq!(ShowEmails::Off, ShowEmails::from_i32(0).unwrap()); assert_eq!(ShowEmails::Off, ShowEmails::from_i32(0).unwrap());
assert_eq!( assert_eq!(ShowEmails::All1, ShowEmails::from_i32(1).unwrap());
ShowEmails::AcceptedContacts,
ShowEmails::from_i32(1).unwrap()
);
assert_eq!(ShowEmails::All, ShowEmails::from_i32(2).unwrap()); assert_eq!(ShowEmails::All, ShowEmails::from_i32(2).unwrap());
} }

View File

@@ -522,7 +522,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 // (`ShowEmails=All` lets Alice actually receive non-delta messages for known
// contacts, the contact is marked as known by creating a chat using `chat_with_contact()`) // 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 alice

View File

@@ -2243,7 +2243,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, true).await? { match from_field_to_contact_id(context, &from, true).await? {
Some(res) => res, Some(res) => res,
None => return Ok(false), None => return Ok(false),
@@ -2257,7 +2257,6 @@ pub(crate) async fn prefetch_should_download(
} }
let is_chat_message = headers.get_header_value(HeaderDef::ChatVersion).is_some(); let is_chat_message = headers.get_header_value(HeaderDef::ChatVersion).is_some();
let accepted_contact = origin.is_known();
let is_reply_to_chat_message = get_prefetch_parent_message(context, headers) let is_reply_to_chat_message = get_prefetch_parent_message(context, headers)
.await? .await?
.map(|parent| match parent.is_dc_message { .map(|parent| match parent.is_dc_message {
@@ -2272,10 +2271,7 @@ pub(crate) async fn prefetch_should_download(
let show = is_autocrypt_setup_message let show = is_autocrypt_setup_message
|| match show_emails { || match show_emails {
ShowEmails::Off => is_chat_message || is_reply_to_chat_message, ShowEmails::Off => is_chat_message || is_reply_to_chat_message,
ShowEmails::AcceptedContacts => { ShowEmails::All | ShowEmails::All1 => true,
is_chat_message || is_reply_to_chat_message || accepted_contact
}
ShowEmails::All => true,
}; };
let should_download = (show && !blocked_contact) || maybe_ndn; let should_download = (show && !blocked_contact) || maybe_ndn;

View File

@@ -775,8 +775,7 @@ async fn add_parts(
chat_id = Some(DC_CHAT_ID_TRASH); chat_id = Some(DC_CHAT_ID_TRASH);
allow_creation = false; allow_creation = false;
} }
ShowEmails::AcceptedContacts => allow_creation = false, ShowEmails::All | ShowEmails::All1 => allow_creation = !is_mdn,
ShowEmails::All => allow_creation = !is_mdn,
} }
} else { } else {
allow_creation = !is_mdn && !is_reaction; allow_creation = !is_mdn && !is_reaction;

View File

@@ -113,11 +113,8 @@ 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( bob.set_config(Config::ShowEmails, Some(&ShowEmails::All.to_string()))
Config::ShowEmails, .await?;
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,