Make it work

Add a mutex to prevent a race condition when a "your pw is wrong" warning is sent, resulting in multiple messeges being sent.

Do not mute the device chat but "only" send MsgsChanged event when no
notification shall be shown.

More logging.
This commit is contained in:
Hocuri
2020-06-13 19:45:59 +02:00
parent 3f2e67f07a
commit 2c23433185
3 changed files with 24 additions and 12 deletions

View File

@@ -308,17 +308,29 @@ impl Imap {
.stock_string_repl_str(StockMessage::CannotLogin, &imap_user)
.await;
warn!(context, "{} ({})", message, err);
error!(context, "{}", message);
let lock = context.wrong_pw_warning_mutex.lock().await;
if self.login_failed_once
&& self.fetch
&& !context.get_config_bool(Config::WarnedAboutWrongPw).await
{
context
if let Err(e) = context
.set_config(Config::WarnedAboutWrongPw, Some("1"))
.await;
.await
{
warn!(context, "{}", e);
}
drop(lock);
let mut msg = Message::new(Viewtype::Text);
msg.text = Some(message);
chat::add_device_msg_with_importance(context, None, Some(&mut msg), true).await;
if let Err(e) =
chat::add_device_msg_with_importance(context, None, Some(&mut msg), true)
.await
{
warn!(context, "{}", e);
}
} else {
self.login_failed_once = true;
}