Move models into shared module and clean imports
Relocate bot and organization models into shared module, update imports and remove unused modules.
This commit is contained in:
parent
ac716981ec
commit
45ab675b21
9 changed files with 41 additions and 43 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -9,7 +9,6 @@ mod context;
|
||||||
mod email;
|
mod email;
|
||||||
mod file;
|
mod file;
|
||||||
mod llm;
|
mod llm;
|
||||||
mod models;
|
|
||||||
mod org;
|
mod org;
|
||||||
mod session;
|
mod session;
|
||||||
mod shared;
|
mod shared;
|
||||||
|
|
@ -17,7 +16,6 @@ mod tools;
|
||||||
mod web_automation;
|
mod web_automation;
|
||||||
mod whatsapp;
|
mod whatsapp;
|
||||||
|
|
||||||
use actix_web::middleware::Logger;
|
|
||||||
use log::info;
|
use log::info;
|
||||||
use qdrant_client::Qdrant;
|
use qdrant_client::Qdrant;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
@ -26,8 +24,8 @@ use actix_web::{web, App, HttpServer};
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|
||||||
|
use crate::auth::AuthService;
|
||||||
use crate::bot::BotOrchestrator;
|
use crate::bot::BotOrchestrator;
|
||||||
use crate::channels::ChannelAdapter;
|
|
||||||
use crate::config::AppConfig;
|
use crate::config::AppConfig;
|
||||||
use crate::email::{
|
use crate::email::{
|
||||||
get_emails, get_latest_email_from, list_emails, save_click, save_draft, send_email,
|
get_emails, get_latest_email_from, list_emails, save_click, save_draft, send_email,
|
||||||
|
|
@ -38,12 +36,9 @@ use crate::llm::llm_local::{
|
||||||
chat_completions_local, embeddings_local, ensure_llama_servers_running,
|
chat_completions_local, embeddings_local, ensure_llama_servers_running,
|
||||||
};
|
};
|
||||||
use crate::session::SessionManager;
|
use crate::session::SessionManager;
|
||||||
use crate::state::AppState;
|
use crate::shared::state::AppState;
|
||||||
use crate::tools::{RedisToolExecutor, ToolManager};
|
use crate::tools::{RedisToolExecutor, ToolManager};
|
||||||
use crate::web_automation::{initialize_browser_pool, BrowserPool};
|
use crate::web_automation::{initialize_browser_pool, BrowserPool};
|
||||||
use crate::whatsapp::WhatsAppAdapter;
|
|
||||||
use crate::AuthService;
|
|
||||||
use crate::BotOrchestrator;
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
|
@ -57,7 +52,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
let db = PgPool::connect(&db_url).await.unwrap();
|
let db = PgPool::connect(&db_url).await.unwrap();
|
||||||
let db_custom = PgPool::connect(&db_custom_url).await.unwrap();
|
let db_custom = PgPool::connect(&db_custom_url).await.unwrap();
|
||||||
|
|
||||||
let minio_client = services::file::init_minio(&config)
|
let minio_client = init_minio(&config)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to initialize Minio");
|
.expect("Failed to initialize Minio");
|
||||||
|
|
||||||
|
|
@ -81,7 +76,8 @@ async fn main() -> std::io::Result<()> {
|
||||||
Ok(redis_url_value) => {
|
Ok(redis_url_value) => {
|
||||||
let client = redis::Client::open(redis_url_value.clone())
|
let client = redis::Client::open(redis_url_value.clone())
|
||||||
.expect("Failed to create Redis client");
|
.expect("Failed to create Redis client");
|
||||||
let conn = redis::aio::Connection::new(client)
|
let conn = client
|
||||||
|
.get_connection()
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create Redis connection");
|
.expect("Failed to create Redis connection");
|
||||||
Some(Arc::new(conn))
|
Some(Arc::new(conn))
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
|
||||||
pub struct Bot {
|
|
||||||
pub bot_id: Uuid,
|
|
||||||
pub name: String,
|
|
||||||
pub status: BotStatus,
|
|
||||||
pub config: serde_json::Value,
|
|
||||||
pub created_at: chrono::DateTime<Utc>,
|
|
||||||
pub updated_at: chrono::DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[sqlx(type_name = "bot_status", rename_all = "snake_case")]
|
|
||||||
pub enum BotStatus {
|
|
||||||
Active,
|
|
||||||
Inactive,
|
|
||||||
Maintenance,
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
use chrono::{DateTime, Utc};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use sqlx::FromRow;
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
|
||||||
pub struct organization {
|
|
||||||
pub org_id: Uuid,
|
|
||||||
pub name: String,
|
|
||||||
pub slug: String,
|
|
||||||
pub created_at: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use actix_web::{web, HttpResponse, Result};
|
use actix_web::{web, HttpResponse, Result};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::Utc;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, PgPool};
|
use sqlx::PgPool;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
pub mod models;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,38 @@ use serde::{Deserialize, Serialize};
|
||||||
use sqlx::FromRow;
|
use sqlx::FromRow;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||||
|
pub struct organization {
|
||||||
|
pub org_id: Uuid,
|
||||||
|
pub name: String,
|
||||||
|
pub slug: String,
|
||||||
|
pub created_at: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||||
|
pub struct Bot {
|
||||||
|
pub bot_id: Uuid,
|
||||||
|
pub name: String,
|
||||||
|
pub status: BotStatus,
|
||||||
|
pub config: serde_json::Value,
|
||||||
|
pub created_at: chrono::DateTime<Utc>,
|
||||||
|
pub updated_at: chrono::DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
#[sqlx(type_name = "bot_status", rename_all = "snake_case")]
|
||||||
|
pub enum BotStatus {
|
||||||
|
Active,
|
||||||
|
Inactive,
|
||||||
|
Maintenance,
|
||||||
|
}
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sqlx::FromRow;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum TriggerKind {
|
pub enum TriggerKind {
|
||||||
Scheduled = 0,
|
Scheduled = 0,
|
||||||
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use minio::s3::Client;
|
use minio::s3::Client;
|
||||||
|
|
||||||
use crate::{config::AppConfig, web_automation::BrowserPool};
|
use crate::{config::AppConfig, web_automator::BrowserPool};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue