add AUTH_REQUIRED for debugging purposes

This commit is contained in:
2026-04-16 10:53:31 +03:00
parent 0aaa0ac76a
commit 486a596154
2 changed files with 19 additions and 1 deletions

View File

@@ -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,

View File

@@ -21,6 +21,7 @@ const APP_NAME: &str = "deltachat-remotecontrol-bot";
const APP_CONFIG_DIR: &str = APP_NAME;
const APP_DATA_DIR: &str = APP_NAME;
const BOT_DISPLAY_NAME: &str = "🤖Remote🖲";
const AUTH_REQUIRED: bool = true;
/// Delta Chat bot for remote control of local network machines.
#[derive(Parser)]