mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
make ShowEmails an enum, use constant for trash
This commit is contained in:
committed by
holger krekel
parent
f5d98c1db6
commit
79a08f96c5
@@ -44,6 +44,20 @@ impl Default for Blocked {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum ShowEmails {
|
||||||
|
Off = 0,
|
||||||
|
AcceptedContacts = 1,
|
||||||
|
All = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ShowEmails {
|
||||||
|
fn default() -> Self {
|
||||||
|
ShowEmails::Off
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub const DC_IMAP_SEEN: u32 = 0x1;
|
pub const DC_IMAP_SEEN: u32 = 0x1;
|
||||||
|
|
||||||
pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01;
|
pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01;
|
||||||
@@ -251,11 +265,6 @@ const DC_ERROR_SEE_STRING: usize = 0; // deprecated;
|
|||||||
const DC_ERROR_SELF_NOT_IN_GROUP: usize = 1; // deprecated;
|
const DC_ERROR_SELF_NOT_IN_GROUP: usize = 1; // deprecated;
|
||||||
const DC_STR_SELFNOTINGRP: usize = 21; // deprecated;
|
const DC_STR_SELFNOTINGRP: usize = 21; // deprecated;
|
||||||
|
|
||||||
/// Values for dc_get|set_config("show_emails")
|
|
||||||
const DC_SHOW_EMAILS_OFF: usize = 0;
|
|
||||||
const DC_SHOW_EMAILS_ACCEPTED_CONTACTS: usize = 1;
|
|
||||||
const DC_SHOW_EMAILS_ALL: usize = 2;
|
|
||||||
|
|
||||||
// TODO: Strings need some doumentation about used placeholders.
|
// TODO: Strings need some doumentation about used placeholders.
|
||||||
// These constants are used to set stock translation strings
|
// These constants are used to set stock translation strings
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use mmime::mailmime::*;
|
|||||||
use mmime::other::*;
|
use mmime::other::*;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
|
use num_traits::FromPrimitive;
|
||||||
|
|
||||||
use crate::blob::BlobObject;
|
use crate::blob::BlobObject;
|
||||||
use crate::chat::{self, Chat};
|
use crate::chat::{self, Chat};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
@@ -368,11 +370,12 @@ unsafe fn add_parts(
|
|||||||
// maybe this can be optimized later, by checking the state before the message body is downloaded
|
// maybe this can be optimized later, by checking the state before the message body is downloaded
|
||||||
let mut allow_creation = 1;
|
let mut allow_creation = 1;
|
||||||
if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage && msgrmsg == 0 {
|
if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage && msgrmsg == 0 {
|
||||||
let show_emails = context.get_config_int(Config::ShowEmails);
|
let show_emails =
|
||||||
if show_emails == 0 {
|
ShowEmails::from_i32(context.get_config_int(Config::ShowEmails)).unwrap_or_default();
|
||||||
*chat_id = 3;
|
if show_emails == ShowEmails::Off {
|
||||||
|
*chat_id = DC_CHAT_ID_TRASH;
|
||||||
allow_creation = 0
|
allow_creation = 0
|
||||||
} else if show_emails == 1 {
|
} else if show_emails == ShowEmails::AcceptedContacts {
|
||||||
allow_creation = 0
|
allow_creation = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,7 +443,7 @@ unsafe fn add_parts(
|
|||||||
if *chat_id == 0 {
|
if *chat_id == 0 {
|
||||||
// check if the message belongs to a mailing list
|
// check if the message belongs to a mailing list
|
||||||
if mime_parser.is_mailinglist_message() {
|
if mime_parser.is_mailinglist_message() {
|
||||||
*chat_id = 3;
|
*chat_id = DC_CHAT_ID_TRASH;
|
||||||
info!(context, "Message belongs to a mailing list and is ignored.",);
|
info!(context, "Message belongs to a mailing list and is ignored.",);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user