* Fetches a full thread with all its messages.
(accessToken: string, threadId: string)
| 255 | * Fetches a full thread with all its messages. |
| 256 | */ |
| 257 | async function fetchThread(accessToken: string, threadId: string): Promise<GmailThread | null> { |
| 258 | const url = `${GMAIL_API_BASE}/threads/${threadId}?format=FULL` |
| 259 | |
| 260 | const response = await fetchWithRetry(url, { |
| 261 | method: 'GET', |
| 262 | headers: { |
| 263 | Authorization: `Bearer ${accessToken}`, |
| 264 | Accept: 'application/json', |
| 265 | }, |
| 266 | }) |
| 267 | |
| 268 | if (!response.ok) { |
| 269 | if (response.status === 404) return null |
| 270 | throw new Error(`Failed to fetch thread ${threadId}: ${response.status}`) |
| 271 | } |
| 272 | |
| 273 | return (await response.json()) as GmailThread |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Resolves label IDs to human-readable label names using a cache. |
no test coverage detected