add AUTH_REQUIRED for debugging purposes
This commit is contained in:
@@ -8,9 +8,13 @@ use deltachat::{
|
||||
message::Message,
|
||||
};
|
||||
use eui48::MacAddress;
|
||||
use russh::{
|
||||
client::AuthResult,
|
||||
keys::PrivateKeyWithHashAlg,
|
||||
};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::config::BotConfig;
|
||||
use crate::{AUTH_REQUIRED, config::BotConfig, data_path};
|
||||
|
||||
pub struct BotContext {
|
||||
authed_contacts: HashSet<ContactId>,
|
||||
@@ -45,6 +49,16 @@ pub async fn auth_command(
|
||||
let mut ctx_lock = ctx.lock().await;
|
||||
let dchat_ctx_lock = dchat_ctx.lock().await;
|
||||
|
||||
if !AUTH_REQUIRED {
|
||||
chat::send_text_msg(
|
||||
&dchat_ctx_lock,
|
||||
chat_id,
|
||||
"Authentication is disabled".to_owned(),
|
||||
)
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if ctx_lock.authed_contacts.contains(&contact_id) {
|
||||
chat::send_text_msg(&dchat_ctx_lock, chat_id, "Already authenticated".to_owned()).await?;
|
||||
return Ok(());
|
||||
@@ -199,6 +213,9 @@ async fn ensure_auth(
|
||||
chat_id: ChatId,
|
||||
contact_id: ContactId,
|
||||
) -> AnyhowResult<bool> {
|
||||
if !AUTH_REQUIRED {
|
||||
return Ok(true);
|
||||
}
|
||||
if !ctx.authed_contacts.contains(&contact_id) {
|
||||
chat::send_text_msg(
|
||||
dchat_ctx,
|
||||
|
||||
Reference in New Issue
Block a user