MCPcopy Index your code
hub / github.com/simstudioai/sim / extractAttachmentInfo

Function extractAttachmentInfo

apps/sim/tools/gmail/utils.ts:189–220  ·  view source on GitHub ↗
(
  payload: any
)

Source from the content-addressed store, hash-verified

187
188// Helper function to extract attachment information from message payload
189export function extractAttachmentInfo(
190 payload: any
191): Array<{ attachmentId: string; filename: string; mimeType: string; size: number }> {
192 const attachments: Array<{
193 attachmentId: string
194 filename: string
195 mimeType: string
196 size: number
197 }> = []
198
199 function processPayloadPart(part: any) {
200 // Check if this part has an attachment
201 if (part.body?.attachmentId && part.filename) {
202 attachments.push({
203 attachmentId: part.body.attachmentId,
204 filename: part.filename,
205 mimeType: part.mimeType || 'application/octet-stream',
206 size: part.body.size || 0,
207 })
208 }
209
210 // Recursively process nested parts
211 if (part.parts && Array.isArray(part.parts)) {
212 part.parts.forEach(processPayloadPart)
213 }
214 }
215
216 // Process the main payload
217 processPayloadPart(payload)
218
219 return attachments
220}
221
222// Helper function to download attachments from Gmail API
223export async function downloadAttachments(

Callers 2

processEmailsFunction · 0.90
processMessageFunction · 0.85

Calls 1

processPayloadPartFunction · 0.85

Tested by

no test coverage detected