Skip to content
← Public packages

@danj/hey-email

HEY.com email for Kody: search threads, read messages, download PDF attachments, and write drafts. Sending is barred until you allow it.

src/message.js

19 lines · 676 B · JavaScript
Raw
import { heyFetch } from './client.js'

/**
 * Fetch a full HEY message by entry/message id.
 * Use when reading body HTML (including trix PDF attachments) — entries list
 * does not include attachment markup.
 *
 * @param {{ messageId: number|string, entryId?: number|string }} input
 * @returns {Promise<any>}
 *
 * @example
 * import getMessage from 'kody:@danj/hey-email/message'
 * const msg = await getMessage({ messageId: 123456789 })
 */
export default async function getMessage(input) {
  const messageId = input?.messageId ?? input?.entryId
  if (messageId == null) throw new Error('messageId is required')
  return await heyFetch(`/messages/${messageId}.json`)
}