Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;
/// Attachments of a message, as sent to us by the provider.
#[derive(FromRow, Debug, Clone, Serialize, Deserialize)]
pub struct Attachment {
/// Cloud reference: open this provider page instead of downloading bytes.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reference_url: Option<String>,
pub id: Uuid,
pub message_id: Uuid,
// a different value is returned by the gmail API for this each time you fetch a message -
// don't make the mistake of using it to uniquely identify an attachment
pub provider_attachment_id: Option<String>,
pub filename: Option<String>,
pub mime_type: Option<String>,
pub size_bytes: Option<i64>,
pub content_id: Option<String>,
pub sfs_id: Option<Uuid>,
pub created_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AttachmentSfs {
pub id: Uuid,
pub attachment_id: Option<Uuid>,
pub sfs_id: Uuid,
}
impl From<crate::service::attachment::AttachmentSfs> for AttachmentSfs {
fn from(service: crate::service::attachment::AttachmentSfs) -> Self {
Self {
id: service.id,
attachment_id: service.attachment_id,
sfs_id: service.sfs_id,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
pub struct AttachmentDraft {
/// Unique identifier for the attachment.
pub id: Uuid,
/// The ID of the draft message this attachment belongs to.
pub draft_id: Uuid,
/// Original file name of the attachment.
pub file_name: String,
/// MIME type of the attachment (e.g., "application/pdf", "image/png").
pub content_type: String,
/// SHA-256 hash of the file content for integrity verification.
pub sha: String,
/// File size in bytes.
pub size: i32,
/// S3 object key where the attachment content is stored.
pub s3_key: String,
/// Bytes have not yet been verified; sending must wait for completion.
#[serde(default)]
pub upload_pending: bool,
/// Original Content-ID retained when transferring a provider attachment.
#[serde(default)]
pub content_id: Option<String>,
/// Whether the attachment is referenced inline by the message body.
#[serde(default)]
pub is_inline: bool,
}
impl From<crate::service::attachment::AttachmentDraft> for AttachmentDraft {
fn from(service: crate::service::attachment::AttachmentDraft) -> Self {
Self {
id: service.id,
draft_id: service.draft_id,
file_name: service.file_name,
content_type: service.content_type,
sha: service.sha,
size: service.size,
s3_key: service.s3_key,
upload_pending: service.upload_pending,
content_id: service.content_id,
is_inline: service.is_inline,
}
}
}
/// A forwarded attachment linking a draft to an original message's attachment.
/// Data is fetched from Gmail at send time rather than stored in S3.
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
pub struct AttachmentForwarded {
/// The UUID of the original attachment in email_attachments.
pub attachment_id: Uuid,
/// The ID of the draft message this forwarded attachment belongs to.
pub draft_id: Uuid,
/// The Gmail attachment ID for fetching data from Gmail API.
pub provider_attachment_id: Option<String>,
/// The Gmail message ID of the original message containing the attachment.
pub message_provider_id: String,
/// Original file name of the attachment.
pub filename: Option<String>,
/// MIME type of the attachment.
pub mime_type: Option<String>,
/// File size in bytes.
pub size_bytes: Option<i64>,
}