From: Erik Mackdanz Date: Mon, 23 Feb 2026 17:03:51 +0000 (-0600) Subject: Drop verify command since this happens automatically now X-Git-Url: https://git.humopery.space/?a=commitdiff_plain;h=ab4a14574897a8b8898a1bd8c7640e266560a044;p=private%2Fmemberbot.git Drop verify command since this happens automatically now --- diff --git a/README.md b/README.md index 328f0fd..e5e7d29 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ A Matrix chatbot for managing organization members with end-to-end encryption su - **Member Management**: Upsert and list organization members via TSV data - **Admin Controls**: Restrict commands to authorized administrators - **E2E Encryption**: Full Matrix end-to-end encryption support -- **Device Verification**: Verify devices for secure communication - **SQLite Database**: Persistent storage of member data and events - **Environment Configuration**: Easy configuration via environment variables @@ -71,7 +70,6 @@ DATABASE_URL=sqlite:memberbot.db - `!list` - List all members - `!setadmin ` - Set a member as admin - `!removeadmin ` - Remove admin status from a member - - `!verify ` - Verify a device for E2E encryption ### TSV Format for `!upsert` @@ -94,13 +92,11 @@ The bot uses SQLite with the following tables: - `members`: Stores member information (ID, email, Matrix user, admin status) - `events`: Logs bot interactions and events -- `device_verifications`: Tracks E2E encryption device verifications ## Security - **Admin-only commands**: Only users marked as `is_admin = TRUE` in the database can use commands - **E2E Encryption**: Full Matrix end-to-end encryption using `matrix-sdk-crypto` -- **Device Verification**: Manual device verification via `/verify` command - **Event Logging**: All bot interactions are logged for audit purposes ## Development diff --git a/migrations/002_drop_verify_command.sql b/migrations/002_drop_verify_command.sql new file mode 100644 index 0000000..da9c6c3 --- /dev/null +++ b/migrations/002_drop_verify_command.sql @@ -0,0 +1,4 @@ +DROP INDEX IF EXISTS idx_device_verifications_device_id; +DROP INDEX IF EXISTS idx_device_verifications_verified; + +DROP TABLE IF EXISTS device_verifications; diff --git a/src/bot.rs b/src/bot.rs index dc478a0..6de86eb 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -332,7 +332,6 @@ async fn handle_message( !list - List all members !setadmin - Set a member as admin !removeadmin - Remove admin status from a member -!verify - Verify a device for E2E encryption "#; if let Err(e) = send_reply(&room, help_text).await { error!("Failed to send help reply: {}", e); @@ -350,9 +349,6 @@ async fn handle_message( "!removeadmin" => { handle_setadmin_command(&room, args, &sender, db, false).await?; } - "!verify" => { - handle_verify_command(&room, args, &sender, db).await?; - } _ => { let reply = format!("Unknown command: {}. Type !help for available commands.", command); if let Err(e) = send_reply(&room, &reply).await { @@ -562,47 +558,6 @@ async fn handle_setadmin_command( Ok(()) } -async fn handle_verify_command( - room: &Room, - args: &[&str], - sender: &UserId, - db: &Database, -) -> Result<()> { - // Check if user is admin - let matrix_user = sender.to_string(); - let is_admin = if let Some(member) = db.get_member_by_matrix_user(&matrix_user).await? { - member.is_admin - } else { - false - }; - - if !is_admin { - let reply = "Error: You must be an admin to use this command."; - send_reply(room, reply).await?; - return Ok(()); - } - - if args.is_empty() { - let reply = "Error: Please provide a device_id. Usage: /verify "; - send_reply(room, reply).await?; - return Ok(()); - } - - let device_id = args[0]; - - match db.verify_device(device_id).await { - Ok(_) => { - let reply = format!("Successfully verified device: {}", device_id); - send_reply(room, &reply).await?; - } - Err(e) => { - let reply = format!("Error: {}", e); - send_reply(room, &reply).await?; - } - } - - Ok(()) -} async fn handle_verification_request(client: Client, request: VerificationRequest) { info!("Processing verification request from {}", request.other_user_id()); diff --git a/src/database.rs b/src/database.rs index d2703f1..30d641d 100644 --- a/src/database.rs +++ b/src/database.rs @@ -2,7 +2,7 @@ use anyhow::{Context, Result}; use sqlx::{sqlite::SqlitePoolOptions, Row, SqlitePool}; use tracing::info; -use crate::models::{DeviceVerification, Member, MemberUpsert}; +use crate::models::{Member, MemberUpsert}; pub struct Database { pool: SqlitePool, @@ -273,81 +273,4 @@ impl Database { Ok(()) } - - // Device verification operations - pub async fn save_device_verification( - &self, - device_id: &str, - public_key: &str, - ) -> Result<()> { - sqlx::query( - r#" - INSERT INTO device_verifications (device_id, public_key) - VALUES (?, ?) - "#, - ) - .bind(device_id) - .bind(public_key) - .execute(&self.pool) - .await - .context("Failed to save device verification")?; - - Ok(()) - } - - pub async fn verify_device(&self, device_id: &str) -> Result<()> { - sqlx::query( - r#" - UPDATE device_verifications - SET verified = TRUE, verified_at = CURRENT_TIMESTAMP - WHERE device_id = ? - "#, - ) - .bind(device_id) - .execute(&self.pool) - .await - .context("Failed to verify device")?; - - // Log event - self.log_event( - "device_verified", - None, - None, - Some(&format!("Verified device: {}", device_id)), - ) - .await?; - - Ok(()) - } - - pub async fn get_device_verification( - &self, - device_id: &str, - ) -> Result> { - let row = sqlx::query( - "SELECT * FROM device_verifications WHERE device_id = ?", - ) - .bind(device_id) - .fetch_optional(&self.pool) - .await - .context("Failed to get device verification")?; - - if let Some(row) = row { - Ok(Some(DeviceVerification { - id: row.get("id"), - device_id: row.get("device_id"), - public_key: row.get("public_key"), - verified: row.get("verified"), - created_at: row.get("created_at"), - verified_at: row.get("verified_at"), - })) - } else { - Ok(None) - } - } - - pub async fn is_device_verified(&self, device_id: &str) -> Result { - let verification = self.get_device_verification(device_id).await?; - Ok(verification.map(|v| v.verified).unwrap_or(false)) - } } diff --git a/src/models.rs b/src/models.rs index 084914a..eae31f4 100644 --- a/src/models.rs +++ b/src/models.rs @@ -21,16 +21,6 @@ pub struct Event { pub created_at: String, } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct DeviceVerification { - pub id: i64, - pub device_id: String, - pub public_key: String, - pub verified: bool, - pub created_at: String, - pub verified_at: Option, -} - #[derive(Debug, Clone, Serialize, Deserialize)] pub struct MemberUpsert { pub member_id: String,