mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
prefer context.get_config() over context.sql.get_config() as the latter does not handle default values.
This commit is contained in:
@@ -951,10 +951,7 @@ pub fn get_chat_msgs(context: &Context, chat_id: u32, flags: u32, marker1before:
|
|||||||
};
|
};
|
||||||
|
|
||||||
let success = if chat_id == 1 {
|
let success = if chat_id == 1 {
|
||||||
let show_emails = context
|
let show_emails = context.get_config_int(Config::ShowEmails);
|
||||||
.sql
|
|
||||||
.get_config_int(context, "show_emails")
|
|
||||||
.unwrap_or_default();
|
|
||||||
context.sql.query_map(
|
context.sql.query_map(
|
||||||
"SELECT m.id, m.timestamp FROM msgs m \
|
"SELECT m.id, m.timestamp FROM msgs m \
|
||||||
LEFT JOIN chats ON m.chat_id=chats.id \
|
LEFT JOIN chats ON m.chat_id=chats.id \
|
||||||
@@ -1373,8 +1370,7 @@ pub(crate) fn add_contact_to_chat_ex(
|
|||||||
chat.update_param(context).unwrap();
|
chat.update_param(context).unwrap();
|
||||||
}
|
}
|
||||||
let self_addr = context
|
let self_addr = context
|
||||||
.sql
|
.get_config(Config::ConfiguredAddr)
|
||||||
.get_config(context, "configured_addr")
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
if contact.get_addr() == &self_addr {
|
if contact.get_addr() == &self_addr {
|
||||||
bail!("invalid attempt to add self e-mail address to group");
|
bail!("invalid attempt to add self e-mail address to group");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
@@ -476,15 +477,8 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context) {
|
|||||||
}
|
}
|
||||||
16 => {
|
16 => {
|
||||||
progress!(context, 900);
|
progress!(context, 900);
|
||||||
let flags: libc::c_int = if 0
|
let flags: libc::c_int = if 0 != context.get_config_int(Config::MvboxWatch)
|
||||||
!= context
|
|| 0 != context.get_config_int(Config::MvboxMove)
|
||||||
.sql
|
|
||||||
.get_config_int(context, "mvbox_watch")
|
|
||||||
.unwrap_or_else(|| 1)
|
|
||||||
|| 0 != context
|
|
||||||
.sql
|
|
||||||
.get_config_int(context, "mvbox_move")
|
|
||||||
.unwrap_or_else(|| 1)
|
|
||||||
{
|
{
|
||||||
DC_CREATE_MVBOX as i32
|
DC_CREATE_MVBOX as i32
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -222,15 +222,12 @@ impl Context {
|
|||||||
let unset = "0";
|
let unset = "0";
|
||||||
let l = LoginParam::from_database(self, "");
|
let l = LoginParam::from_database(self, "");
|
||||||
let l2 = LoginParam::from_database(self, "configured_");
|
let l2 = LoginParam::from_database(self, "configured_");
|
||||||
let displayname = self.sql.get_config(self, "displayname");
|
let displayname = self.get_config(Config::Displayname);
|
||||||
let chats = get_chat_cnt(self) as usize;
|
let chats = get_chat_cnt(self) as usize;
|
||||||
let real_msgs = message::get_real_msg_cnt(self) as usize;
|
let real_msgs = message::get_real_msg_cnt(self) as usize;
|
||||||
let deaddrop_msgs = message::get_deaddrop_msg_cnt(self) as usize;
|
let deaddrop_msgs = message::get_deaddrop_msg_cnt(self) as usize;
|
||||||
let contacts = Contact::get_real_cnt(self) as usize;
|
let contacts = Contact::get_real_cnt(self) as usize;
|
||||||
let is_configured = self
|
let is_configured = self.get_config_int(Config::Configured);
|
||||||
.sql
|
|
||||||
.get_config_int(self, "configured")
|
|
||||||
.unwrap_or_default();
|
|
||||||
let dbversion = self
|
let dbversion = self
|
||||||
.sql
|
.sql
|
||||||
.get_config_int(self, "dbversion")
|
.get_config_int(self, "dbversion")
|
||||||
@@ -394,12 +391,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn do_heuristics_moves(&self, folder: &str, msg_id: u32) {
|
pub fn do_heuristics_moves(&self, folder: &str, msg_id: u32) {
|
||||||
if self
|
if self.get_config_int(Config::MvboxMove) == 0 {
|
||||||
.sql
|
|
||||||
.get_config_int(self, "mvbox_move")
|
|
||||||
.unwrap_or_else(|| 1)
|
|
||||||
== 0
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ unsafe fn add_parts(
|
|||||||
|
|
||||||
// if the mime-headers should be saved, find out its size
|
// if the mime-headers should be saved, find out its size
|
||||||
// (the mime-header ends with an empty line)
|
// (the mime-header ends with an empty line)
|
||||||
let save_mime_headers = context.sql.get_config_bool(context, "save_mime_headers");
|
let save_mime_headers = context.get_config_bool(Config::SaveMimeHeaders);
|
||||||
if let Some(field) = mime_parser.lookup_field_typ("In-Reply-To", MAILIMF_FIELD_IN_REPLY_TO) {
|
if let Some(field) = mime_parser.lookup_field_typ("In-Reply-To", MAILIMF_FIELD_IN_REPLY_TO) {
|
||||||
let fld_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
let fld_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||||
if !fld_in_reply_to.is_null() {
|
if !fld_in_reply_to.is_null() {
|
||||||
@@ -853,10 +853,7 @@ unsafe fn handle_reports(
|
|||||||
param.set(Param::ServerFolder, server_folder.as_ref());
|
param.set(Param::ServerFolder, server_folder.as_ref());
|
||||||
param.set_int(Param::ServerUid, server_uid as i32);
|
param.set_int(Param::ServerUid, server_uid as i32);
|
||||||
if mime_parser.is_send_by_messenger
|
if mime_parser.is_send_by_messenger
|
||||||
&& 0 != context
|
&& 0 != context.get_config_int(Config::MvboxMove)
|
||||||
.sql
|
|
||||||
.get_config_int(context, "mvbox_move")
|
|
||||||
.unwrap_or_else(|| 1)
|
|
||||||
{
|
{
|
||||||
param.set_int(Param::AlsoMove, 1);
|
param.set_int(Param::AlsoMove, 1);
|
||||||
}
|
}
|
||||||
@@ -1159,8 +1156,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
group_explicitly_left = chat::is_group_explicitly_left(context, &grpid).unwrap_or_default();
|
group_explicitly_left = chat::is_group_explicitly_left(context, &grpid).unwrap_or_default();
|
||||||
|
|
||||||
let self_addr = context
|
let self_addr = context
|
||||||
.sql
|
.get_config(Config::ConfiguredAddr)
|
||||||
.get_config(context, "configured_addr")
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
if chat_id == 0
|
if chat_id == 0
|
||||||
&& !mime_parser.is_mailinglist_message()
|
&& !mime_parser.is_mailinglist_message()
|
||||||
@@ -1490,8 +1486,7 @@ fn create_adhoc_grp_id(context: &Context, member_ids: &[u32]) -> String {
|
|||||||
*/
|
*/
|
||||||
let member_ids_str = join(member_ids.iter().map(|x| x.to_string()), ",");
|
let member_ids_str = join(member_ids.iter().map(|x| x.to_string()), ",");
|
||||||
let member_cs = context
|
let member_cs = context
|
||||||
.sql
|
.get_config(Config::ConfiguredAddr)
|
||||||
.get_config(context, "configured_addr")
|
|
||||||
.unwrap_or_else(|| "no-self".to_string())
|
.unwrap_or_else(|| "no-self".to_string())
|
||||||
.to_lowercase();
|
.to_lowercase();
|
||||||
|
|
||||||
@@ -1942,8 +1937,7 @@ unsafe fn add_or_lookup_contact_by_addr(
|
|||||||
}
|
}
|
||||||
*check_self = 0;
|
*check_self = 0;
|
||||||
let self_addr = context
|
let self_addr = context
|
||||||
.sql
|
.get_config(Config::ConfiguredAddr)
|
||||||
.get_config(context, "configured_addr")
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
if addr_cmp(self_addr, as_str(addr_spec)) {
|
if addr_cmp(self_addr, as_str(addr_spec)) {
|
||||||
|
|||||||
27
src/job.rs
27
src/job.rs
@@ -364,12 +364,7 @@ pub fn perform_imap_fetch(context: &Context) {
|
|||||||
if 0 == connect_to_inbox(context, &inbox) {
|
if 0 == connect_to_inbox(context, &inbox) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if context
|
if context.get_config_int(Config::InboxWatch) == 0 {
|
||||||
.sql
|
|
||||||
.get_config_int(context, "inbox_watch")
|
|
||||||
.unwrap_or_else(|| 1)
|
|
||||||
== 0
|
|
||||||
{
|
|
||||||
info!(context, "INBOX-watch disabled.",);
|
info!(context, "INBOX-watch disabled.",);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -404,10 +399,7 @@ pub fn perform_imap_idle(context: &Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn perform_mvbox_fetch(context: &Context) {
|
pub fn perform_mvbox_fetch(context: &Context) {
|
||||||
let use_network = context
|
let use_network = context.get_config_int(Config::MvboxWatch);
|
||||||
.sql
|
|
||||||
.get_config_int(context, "mvbox_watch")
|
|
||||||
.unwrap_or_else(|| 1);
|
|
||||||
|
|
||||||
context
|
context
|
||||||
.mvbox_thread
|
.mvbox_thread
|
||||||
@@ -417,10 +409,7 @@ pub fn perform_mvbox_fetch(context: &Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn perform_mvbox_idle(context: &Context) {
|
pub fn perform_mvbox_idle(context: &Context) {
|
||||||
let use_network = context
|
let use_network = context.get_config_int(Config::MvboxWatch);
|
||||||
.sql
|
|
||||||
.get_config_int(context, "mvbox_watch")
|
|
||||||
.unwrap_or_else(|| 1);
|
|
||||||
|
|
||||||
context
|
context
|
||||||
.mvbox_thread
|
.mvbox_thread
|
||||||
@@ -434,10 +423,7 @@ pub fn interrupt_mvbox_idle(context: &Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn perform_sentbox_fetch(context: &Context) {
|
pub fn perform_sentbox_fetch(context: &Context) {
|
||||||
let use_network = context
|
let use_network = context.get_config_int(Config::SentboxWatch);
|
||||||
.sql
|
|
||||||
.get_config_int(context, "sentbox_watch")
|
|
||||||
.unwrap_or_else(|| 1);
|
|
||||||
|
|
||||||
context
|
context
|
||||||
.sentbox_thread
|
.sentbox_thread
|
||||||
@@ -447,10 +433,7 @@ pub fn perform_sentbox_fetch(context: &Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn perform_sentbox_idle(context: &Context) {
|
pub fn perform_sentbox_idle(context: &Context) {
|
||||||
let use_network = context
|
let use_network = context.get_config_int(Config::SentboxWatch);
|
||||||
.sql
|
|
||||||
.get_config_int(context, "sentbox_watch")
|
|
||||||
.unwrap_or_else(|| 1);
|
|
||||||
|
|
||||||
context
|
context
|
||||||
.sentbox_thread
|
.sentbox_thread
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use quick_xml;
|
|||||||
use quick_xml::events::{BytesEnd, BytesStart, BytesText};
|
use quick_xml::events::{BytesEnd, BytesStart, BytesText};
|
||||||
|
|
||||||
use crate::chat;
|
use crate::chat;
|
||||||
|
use crate::config::Config;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::context::*;
|
use crate::context::*;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
@@ -375,8 +376,7 @@ pub fn get_kml(context: &Context, chat_id: u32) -> Result<(String, u32), Error>
|
|||||||
let mut last_added_location_id = 0;
|
let mut last_added_location_id = 0;
|
||||||
|
|
||||||
let self_addr = context
|
let self_addr = context
|
||||||
.sql
|
.get_config(Config::ConfiguredAddr)
|
||||||
.get_config(context, "configured_addr")
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let (locations_send_begin, locations_send_until, locations_last_sent) = context.sql.query_row(
|
let (locations_send_begin, locations_send_until, locations_last_sent) = context.sql.query_row(
|
||||||
|
|||||||
@@ -60,11 +60,13 @@ pub struct MimeFactory<'a> {
|
|||||||
|
|
||||||
impl<'a> MimeFactory<'a> {
|
impl<'a> MimeFactory<'a> {
|
||||||
fn new(context: &'a Context, msg: Message) -> Self {
|
fn new(context: &'a Context, msg: Message) -> Self {
|
||||||
let cget = |context: &Context, name: &str| context.sql.get_config(context, name);
|
|
||||||
MimeFactory {
|
MimeFactory {
|
||||||
from_addr: cget(&context, "configured_addr").unwrap_or_default(),
|
from_addr: context
|
||||||
from_displayname: cget(&context, "displayname").unwrap_or_default(),
|
.get_config(Config::ConfiguredAddr)
|
||||||
selfstatus: cget(&context, "selfstatus")
|
.unwrap_or_default(),
|
||||||
|
from_displayname: context.get_config(Config::Displayname).unwrap_or_default(),
|
||||||
|
selfstatus: context
|
||||||
|
.get_config(Config::Selfstatus)
|
||||||
.unwrap_or_else(|| context.stock_str(StockMessage::StatusLine).to_string()),
|
.unwrap_or_else(|| context.stock_str(StockMessage::StatusLine).to_string()),
|
||||||
recipients_names: Vec::with_capacity(5),
|
recipients_names: Vec::with_capacity(5),
|
||||||
recipients_addr: Vec::with_capacity(5),
|
recipients_addr: Vec::with_capacity(5),
|
||||||
@@ -703,8 +705,7 @@ impl<'a> MimeFactory<'a> {
|
|||||||
let email_to_remove = msg.param.get(Param::Arg).unwrap_or_default();
|
let email_to_remove = msg.param.get(Param::Arg).unwrap_or_default();
|
||||||
|
|
||||||
let self_addr = context
|
let self_addr = context
|
||||||
.sql
|
.get_config(Config::ConfiguredAddr)
|
||||||
.get_config(context, "configured_addr")
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
if !email_to_remove.is_empty() && email_to_remove != self_addr {
|
if !email_to_remove.is_empty() && email_to_remove != self_addr {
|
||||||
|
|||||||
@@ -82,10 +82,7 @@ pub fn dc_get_securejoin_qr(context: &Context, group_chat_id: u32) -> Option<Str
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let self_name = context
|
let self_name = context.get_config(Config::Displayname).unwrap_or_default();
|
||||||
.sql
|
|
||||||
.get_config(context, "displayname")
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
fingerprint = match get_self_fingerprint(context) {
|
fingerprint = match get_self_fingerprint(context) {
|
||||||
Some(fp) => fp,
|
Some(fp) => fp,
|
||||||
|
|||||||
Reference in New Issue
Block a user