Covers phases 1-2 of the build order in the architecture spec: the IMAP sync engine (IDLE + UIDVALIDITY tracking + jittered reconnect, headers first with lazy body fetch), the full data model, and a minimal REST API for auth, accounts, folders, messages and delta polling. Credentials are encrypted at rest with ChaCha20-Poly1305 rather than libsodium secretbox, to avoid a system dependency for the same construction. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
59 lines
1.6 KiB
Rust
59 lines
1.6 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::Serialize;
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Debug, Clone, sqlx::FromRow, Serialize)]
|
|
pub struct Message {
|
|
pub id: Uuid,
|
|
pub account_id: Uuid,
|
|
pub folder_id: Option<Uuid>,
|
|
pub uid: i64,
|
|
pub message_id: Option<String>,
|
|
pub in_reply_to: Option<String>,
|
|
pub references_: Vec<String>,
|
|
pub thread_id: Uuid,
|
|
pub from_addr: Option<String>,
|
|
pub from_name: Option<String>,
|
|
pub to_addrs: Vec<String>,
|
|
pub cc_addrs: Vec<String>,
|
|
pub subject: Option<String>,
|
|
pub sent_at: Option<DateTime<Utc>>,
|
|
pub flags: Vec<String>,
|
|
pub spam_score: Option<f32>,
|
|
pub body_fetched: bool,
|
|
pub raw_blob_ref: Option<String>,
|
|
pub created_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, sqlx::FromRow, Serialize)]
|
|
pub struct Body {
|
|
pub message_id: Uuid,
|
|
pub text_body: Option<String>,
|
|
pub html_body: Option<String>,
|
|
}
|
|
|
|
/// Fields extracted from a raw MIME message, ready to insert (imap_sync::parse).
|
|
#[derive(Debug, Clone)]
|
|
pub struct ParsedMessage {
|
|
pub message_id: Option<String>,
|
|
pub in_reply_to: Option<String>,
|
|
pub references: Vec<String>,
|
|
pub from_addr: Option<String>,
|
|
pub from_name: Option<String>,
|
|
pub to_addrs: Vec<String>,
|
|
pub cc_addrs: Vec<String>,
|
|
pub subject: Option<String>,
|
|
pub sent_at: Option<DateTime<Utc>>,
|
|
pub text_body: Option<String>,
|
|
pub html_body: Option<String>,
|
|
pub attachments: Vec<ParsedAttachment>,
|
|
pub raw: Vec<u8>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct ParsedAttachment {
|
|
pub filename: Option<String>,
|
|
pub content_type: Option<String>,
|
|
pub data: Vec<u8>,
|
|
}
|