More explicit

This commit is contained in:
Hocuri
2020-06-13 20:26:16 +02:00
parent ae2fd4014a
commit 86bc54508f
4 changed files with 9 additions and 7 deletions

View File

@@ -2670,6 +2670,7 @@ pub(crate) async fn get_chat_id_by_grpid(
/// Adds a message to device chat. /// Adds a message to device chat.
/// ///
/// Optional `label` can be provided to ensure that message is added only once. /// Optional `label` can be provided to ensure that message is added only once.
/// If `important` is true, a notification will be sent.
pub async fn add_device_msg_with_importance( pub async fn add_device_msg_with_importance(
context: &Context, context: &Context,
label: Option<&str>, label: Option<&str>,

View File

@@ -119,7 +119,9 @@ pub enum Config {
SysConfigKeys, SysConfigKeys,
#[strum(props(default = "0"))] #[strum(props(default = "0"))]
WarnedAboutWrongPw, /// Whether we send a warning if the password is wrong (set to false when we send a warning
/// because we do not want to send a second warning)
NotifyAboutWrongPw,
} }
impl Context { impl Context {

View File

@@ -72,6 +72,7 @@ impl Context {
let mut param = LoginParam::from_database(self, "").await; let mut param = LoginParam::from_database(self, "").await;
let success = configure(self, &mut param).await; let success = configure(self, &mut param).await;
self.set_config(Config::NotifyAboutWrongPw, None).await?;
if let Some(provider) = provider::get_provider_info(&param.addr) { if let Some(provider) = provider::get_provider_info(&param.addr) {
if let Some(config_defaults) = &provider.config_defaults { if let Some(config_defaults) = &provider.config_defaults {
@@ -102,7 +103,8 @@ impl Context {
match success { match success {
Ok(_) => { Ok(_) => {
self.set_config(Config::WarnedAboutWrongPw, None).await?; self.set_config(Config::NotifyAboutWrongPw, Some("1"))
.await?;
progress!(self, 1000); progress!(self, 1000);
Ok(()) Ok(())
} }

View File

@@ -313,12 +313,9 @@ impl Imap {
let lock = context.wrong_pw_warning_mutex.lock().await; let lock = context.wrong_pw_warning_mutex.lock().await;
if self.login_failed_once if self.login_failed_once
&& !context.get_config_bool(Config::WarnedAboutWrongPw).await && context.get_config_bool(Config::NotifyAboutWrongPw).await
{ {
if let Err(e) = context if let Err(e) = context.set_config(Config::NotifyAboutWrongPw, None).await {
.set_config(Config::WarnedAboutWrongPw, Some("1"))
.await
{
warn!(context, "{}", e); warn!(context, "{}", e);
} }
drop(lock); drop(lock);