MCPcopy Create free account
hub / github.com/QLHazyCoder/FlowPilot / normalizeCloudflareTempEmailMessage

Function normalizeCloudflareTempEmailMessage

cloudflare-temp-email-utils.js:321–371  ·  view source on GitHub ↗
(row = {})

Source from the content-addressed store, hash-verified

319 }
320
321 function normalizeCloudflareTempEmailMessage(row = {}) {
322 if (!row || typeof row !== 'object') return null;
323
324 const address = normalizeCloudflareTempEmailAddress(firstNonEmptyString([
325 row.address,
326 row.mail_address,
327 row.email,
328 row.recipient,
329 ]));
330 const raw = firstNonEmptyString([row.raw, row.source, row.mime, row.message]);
331 const parsedMime = raw ? extractTextFromMime(raw) : { headers: {}, text: '' };
332 const subject = decodeMimeEncodedWords(firstNonEmptyString([
333 row.subject,
334 parsedMime.headers.subject,
335 ]));
336 const fromAddress = decodeMimeEncodedWords(firstNonEmptyString([
337 row.from,
338 row.sender,
339 row.mail_from,
340 parsedMime.headers.from,
341 ]));
342 const bodyPreview = firstNonEmptyString([
343 row.text,
344 row.preview,
345 row.body,
346 parsedMime.text,
347 raw,
348 ]).replace(/\s+/g, ' ').trim();
349
350 return {
351 id: firstNonEmptyString([row.id, row.mail_id]),
352 address,
353 addressId: firstNonEmptyString([row.address_id, row.addressId]),
354 subject,
355 from: {
356 emailAddress: {
357 address: fromAddress,
358 },
359 },
360 bodyPreview,
361 raw,
362 receivedDateTime: normalizeReceivedDateTime(firstNonEmptyString([
363 row.receivedDateTime,
364 row.received_at,
365 row.created_at,
366 row.createdAt,
367 row.updated_at,
368 row.date,
369 ])),
370 };
371 }
372
373 function normalizeCloudflareTempEmailMailApiMessages(payload) {
374 return getCloudflareTempEmailMailRows(payload)

Calls 5

extractTextFromMimeFunction · 0.85
decodeMimeEncodedWordsFunction · 0.85
firstNonEmptyStringFunction · 0.70

Tested by

no test coverage detected