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 serde::{Deserialize, Serialize};
use std::fmt;
use std::str::FromStr;
/// Gmail system label IDs. These are IDs built-in to Gmail for all users.
pub enum SystemLabelID {
Inbox,
Spam,
Trash,
Unread,
Starred,
Important,
Sent,
Draft,
CategoryPersonal,
CategorySocial,
CategoryPromotions,
CategoryUpdates,
CategoryForums,
}
impl SystemLabelID {
pub fn is_manually_modifiable(&self) -> bool {
match self {
Self::Inbox => true,
Self::Spam => true,
Self::Trash => true,
Self::Unread => true,
Self::Starred => true,
Self::Important => true,
Self::Sent => false,
Self::Draft => false,
Self::CategoryPersonal => true,
Self::CategorySocial => true,
Self::CategoryPromotions => true,
Self::CategoryUpdates => true,
Self::CategoryForums => true,
}
}
pub fn as_str(&self) -> &'static str {
match self {
Self::Inbox => crate::email::service::label::system_labels::INBOX,
Self::Spam => crate::email::service::label::system_labels::SPAM,
Self::Trash => crate::email::service::label::system_labels::TRASH,
Self::Unread => crate::email::service::label::system_labels::UNREAD,
Self::Starred => crate::email::service::label::system_labels::STARRED,
Self::Important => crate::email::service::label::system_labels::IMPORTANT,
Self::Sent => crate::email::service::label::system_labels::SENT,
Self::Draft => crate::email::service::label::system_labels::DRAFT,
Self::CategoryPersonal => "CATEGORY_PERSONAL",
Self::CategorySocial => "CATEGORY_SOCIAL",
Self::CategoryPromotions => "CATEGORY_PROMOTIONS",
Self::CategoryUpdates => "CATEGORY_UPDATES",
Self::CategoryForums => "CATEGORY_FORUMS",
}
}
}
impl AsRef<str> for SystemLabelID {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<SystemLabelID> for String {
fn from(label: SystemLabelID) -> Self {
label.as_str().to_string()
}
}
impl FromStr for SystemLabelID {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
s if s == crate::email::service::label::system_labels::INBOX => Ok(Self::Inbox),
s if s == crate::email::service::label::system_labels::SPAM => Ok(Self::Spam),
s if s == crate::email::service::label::system_labels::TRASH => Ok(Self::Trash),
s if s == crate::email::service::label::system_labels::UNREAD => Ok(Self::Unread),
s if s == crate::email::service::label::system_labels::STARRED => Ok(Self::Starred),
s if s == crate::email::service::label::system_labels::IMPORTANT => Ok(Self::Important),
s if s == crate::email::service::label::system_labels::SENT => Ok(Self::Sent),
s if s == crate::email::service::label::system_labels::DRAFT => Ok(Self::Draft),
"CATEGORY_PERSONAL" => Ok(Self::CategoryPersonal),
"CATEGORY_SOCIAL" => Ok(Self::CategorySocial),
"CATEGORY_PROMOTIONS" => Ok(Self::CategoryPromotions),
"CATEGORY_UPDATES" => Ok(Self::CategoryUpdates),
"CATEGORY_FORUMS" => Ok(Self::CategoryForums),
_ => Err(format!("Unknown system label: {}", s)),
}
}
}
impl fmt::Display for SystemLabelID {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}
/// Represents the color information for a Gmail label
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GmailLabelColor {
pub text_color: Option<String>,
pub background_color: Option<String>,
}
/// Represents a single Gmail label as returned by the Gmail API
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GmailLabel {
pub id: Option<String>,
pub name: String,
#[serde(rename = "messageListVisibility", default)]
pub message_list_visibility: Option<String>,
#[serde(rename = "labelListVisibility", default)]
pub label_list_visibility: Option<String>,
#[serde(rename = "type", default)]
pub type_: Option<String>,
pub color: Option<GmailLabelColor>,
}
/// Represents the top-level response from Gmail API containing a list of labels
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GmailLabelsResponse {
pub labels: Vec<GmailLabel>,
}