|
19 | 19 | from email import encoders |
20 | 20 | from email.utils import formataddr |
21 | 21 |
|
22 | | -from fastapi import Body |
| 22 | +from fastapi import Body as BodyParam |
23 | 23 | from pydantic import Field |
24 | 24 |
|
25 | 25 | from auth.service_decorator import require_google_service |
@@ -989,33 +989,33 @@ async def get_gmail_attachment_content( |
989 | 989 | async def send_gmail_message( |
990 | 990 | service, |
991 | 991 | user_google_email: str, |
992 | | - to: str = Body(..., description="Recipient email address."), |
993 | | - subject: str = Body(..., description="Email subject."), |
994 | | - body: str = Body(..., description="Email body content (plain text or HTML)."), |
995 | | - body_format: Literal["plain", "html"] = Body( |
| 992 | + to: str = BodyParam(..., description="Recipient email address."), |
| 993 | + subject: str = BodyParam(..., description="Email subject."), |
| 994 | + body: str = BodyParam(..., description="Email body content (plain text or HTML)."), |
| 995 | + body_format: Literal["plain", "html"] = BodyParam( |
996 | 996 | "plain", |
997 | 997 | description="Email body format. Use 'plain' for plaintext or 'html' for HTML content.", |
998 | 998 | ), |
999 | | - cc: Optional[str] = Body(None, description="Optional CC email address."), |
1000 | | - bcc: Optional[str] = Body(None, description="Optional BCC email address."), |
1001 | | - from_name: Optional[str] = Body( |
| 999 | + cc: Optional[str] = BodyParam(None, description="Optional CC email address."), |
| 1000 | + bcc: Optional[str] = BodyParam(None, description="Optional BCC email address."), |
| 1001 | + from_name: Optional[str] = BodyParam( |
1002 | 1002 | None, |
1003 | 1003 | description="Optional sender display name (e.g., 'Peter Hartree'). If provided, the From header will be formatted as 'Name <email>'.", |
1004 | 1004 | ), |
1005 | | - from_email: Optional[str] = Body( |
| 1005 | + from_email: Optional[str] = BodyParam( |
1006 | 1006 | None, |
1007 | 1007 | description="Optional 'Send As' alias email address. Must be configured in Gmail settings (Settings > Accounts > Send mail as). If not provided, uses the authenticated user's email.", |
1008 | 1008 | ), |
1009 | | - thread_id: Optional[str] = Body( |
| 1009 | + thread_id: Optional[str] = BodyParam( |
1010 | 1010 | None, description="Optional Gmail thread ID to reply within." |
1011 | 1011 | ), |
1012 | | - in_reply_to: Optional[str] = Body( |
| 1012 | + in_reply_to: Optional[str] = BodyParam( |
1013 | 1013 | None, description="Optional Message-ID of the message being replied to." |
1014 | 1014 | ), |
1015 | | - references: Optional[str] = Body( |
| 1015 | + references: Optional[str] = BodyParam( |
1016 | 1016 | None, description="Optional chain of Message-IDs for proper threading." |
1017 | 1017 | ), |
1018 | | - attachments: Optional[List[Dict[str, str]]] = Body( |
| 1018 | + attachments: Optional[List[Dict[str, str]]] = BodyParam( |
1019 | 1019 | None, |
1020 | 1020 | description='Optional list of attachments. Each can have: "path" (file path, auto-encodes), OR "content" (standard base64, not urlsafe) + "filename". Optional "mime_type". Example: [{"path": "/path/to/file.pdf"}] or [{"filename": "doc.pdf", "content": "base64data", "mime_type": "application/pdf"}]', |
1021 | 1021 | ), |
@@ -1161,33 +1161,35 @@ async def send_gmail_message( |
1161 | 1161 | async def draft_gmail_message( |
1162 | 1162 | service, |
1163 | 1163 | user_google_email: str, |
1164 | | - subject: str = Body(..., description="Email subject."), |
1165 | | - body: str = Body(..., description="Email body (plain text)."), |
1166 | | - body_format: Literal["plain", "html"] = Body( |
| 1164 | + subject: str = BodyParam(..., description="Email subject."), |
| 1165 | + body: str = BodyParam(..., description="Email body (plain text)."), |
| 1166 | + body_format: Literal["plain", "html"] = BodyParam( |
1167 | 1167 | "plain", |
1168 | 1168 | description="Email body format. Use 'plain' for plaintext or 'html' for HTML content.", |
1169 | 1169 | ), |
1170 | | - to: Optional[str] = Body(None, description="Optional recipient email address."), |
1171 | | - cc: Optional[str] = Body(None, description="Optional CC email address."), |
1172 | | - bcc: Optional[str] = Body(None, description="Optional BCC email address."), |
1173 | | - from_name: Optional[str] = Body( |
| 1170 | + to: Optional[str] = BodyParam( |
| 1171 | + None, description="Optional recipient email address." |
| 1172 | + ), |
| 1173 | + cc: Optional[str] = BodyParam(None, description="Optional CC email address."), |
| 1174 | + bcc: Optional[str] = BodyParam(None, description="Optional BCC email address."), |
| 1175 | + from_name: Optional[str] = BodyParam( |
1174 | 1176 | None, |
1175 | 1177 | description="Optional sender display name (e.g., 'Peter Hartree'). If provided, the From header will be formatted as 'Name <email>'.", |
1176 | 1178 | ), |
1177 | | - from_email: Optional[str] = Body( |
| 1179 | + from_email: Optional[str] = BodyParam( |
1178 | 1180 | None, |
1179 | 1181 | description="Optional 'Send As' alias email address. Must be configured in Gmail settings (Settings > Accounts > Send mail as). If not provided, uses the authenticated user's email.", |
1180 | 1182 | ), |
1181 | | - thread_id: Optional[str] = Body( |
| 1183 | + thread_id: Optional[str] = BodyParam( |
1182 | 1184 | None, description="Optional Gmail thread ID to reply within." |
1183 | 1185 | ), |
1184 | | - in_reply_to: Optional[str] = Body( |
| 1186 | + in_reply_to: Optional[str] = BodyParam( |
1185 | 1187 | None, description="Optional Message-ID of the message being replied to." |
1186 | 1188 | ), |
1187 | | - references: Optional[str] = Body( |
| 1189 | + references: Optional[str] = BodyParam( |
1188 | 1190 | None, description="Optional chain of Message-IDs for proper threading." |
1189 | 1191 | ), |
1190 | | - attachments: Optional[List[Dict[str, str]]] = Body( |
| 1192 | + attachments: Optional[List[Dict[str, str]]] = BodyParam( |
1191 | 1193 | None, |
1192 | 1194 | description="Optional list of attachments. Each can have: 'path' (file path, auto-encodes), OR 'content' (standard base64, not urlsafe) + 'filename'. Optional 'mime_type' (auto-detected from path if not provided).", |
1193 | 1195 | ), |
@@ -1737,10 +1739,10 @@ async def list_gmail_filters(service, user_google_email: str) -> str: |
1737 | 1739 | async def create_gmail_filter( |
1738 | 1740 | service, |
1739 | 1741 | user_google_email: str, |
1740 | | - criteria: Dict[str, Any] = Body( |
| 1742 | + criteria: Dict[str, Any] = BodyParam( |
1741 | 1743 | ..., description="Filter criteria object as defined in the Gmail API." |
1742 | 1744 | ), |
1743 | | - action: Dict[str, Any] = Body( |
| 1745 | + action: Dict[str, Any] = BodyParam( |
1744 | 1746 | ..., description="Filter action object as defined in the Gmail API." |
1745 | 1747 | ), |
1746 | 1748 | ) -> str: |
|
0 commit comments