Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

2.4 KB
Raw Blame
use chrono::{DateTime, Utc};

use super::message::Message;

/// Canonical persisted metadata lazily exposed for an email thread.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EmailThreadMetadata {
    /// Database ID of the thread.
    pub thread_id: uuid::Uuid,
    /// Canonical email link that owns the thread.
    pub link_id: uuid::Uuid,
    /// Whether any message was received rather than drafted or sent.
    pub has_received_mail: bool,
    /// Timestamp of the latest inbound message, when one exists.
    pub latest_inbound_message_ts: Option<DateTime<Utc>>,
    /// Timestamp of the latest outbound message, when one exists: the SENT view's sort key.
    pub latest_outbound_message_ts: Option<DateTime<Utc>>,
    /// Timestamp of the latest message that is not spam, when one exists: the sort key
    /// of every mail view except INBOX and SENT.
    pub latest_non_spam_message_ts: Option<DateTime<Utc>>,
    /// Most recent explicit return from an email reminder, independent of message recency.
    pub reminder_returned_at: Option<DateTime<Utc>>,
}

/// A thread record without messages.
#[derive(Debug, Clone)]
pub struct ThreadRow {
    /// Database ID of the thread.
    pub db_id: uuid::Uuid,
    /// Provider thread ID.
    pub provider_id: Option<String>,
    /// Link ID this thread belongs to.
    pub link_id: uuid::Uuid,
    /// Whether the thread is visible in the inbox.
    pub inbox_visible: bool,
    /// Whether the thread has been read.
    pub is_read: bool,
    /// Whether any message was received rather than drafted or sent, the
    /// condition for returning the thread to the inbox.
    pub has_received_mail: bool,
    /// Timestamp of the latest inbound message.
    pub latest_inbound_message_ts: Option<DateTime<Utc>>,
    /// Timestamp of the latest outbound message.
    pub latest_outbound_message_ts: Option<DateTime<Utc>>,
    /// Timestamp of the latest non-spam message.
    pub latest_non_spam_message_ts: Option<DateTime<Utc>>,
    /// When the thread was created.
    pub created_at: DateTime<Utc>,
    /// When the thread was last updated.
    pub updated_at: DateTime<Utc>,
    /// The project this thread belongs to, if any.
    pub project_id: Option<String>,
}

/// A fully assembled email thread with paginated messages.
#[derive(Debug, Clone)]
pub struct Thread {
    /// The thread metadata.
    pub row: ThreadRow,
    /// Paginated messages in the thread.
    pub messages: Vec<Message>,
}