( workspaceId: string, message: AgentMailWebhookPayload['message'], reason: RejectionReason )
| 327 | } |
| 328 | |
| 329 | async function createRejectedTask( |
| 330 | workspaceId: string, |
| 331 | message: AgentMailWebhookPayload['message'], |
| 332 | reason: RejectionReason |
| 333 | ): Promise<void> { |
| 334 | await db.insert(mothershipInboxTask).values({ |
| 335 | id: generateId(), |
| 336 | workspaceId, |
| 337 | fromEmail: extractSenderEmail(message.from_) || 'unknown', |
| 338 | fromName: extractDisplayName(message.from_), |
| 339 | subject: message.subject || '(no subject)', |
| 340 | bodyPreview: (message.text || '').substring(0, 200) || null, |
| 341 | emailMessageId: message.message_id, |
| 342 | agentmailMessageId: message.message_id, |
| 343 | status: 'rejected', |
| 344 | rejectionReason: reason, |
| 345 | hasAttachments: (message.attachments?.length ?? 0) > 0, |
| 346 | }) |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Extract the raw email address from AgentMail's from_ field. |
no test coverage detected