(batch: MessageBatch<ChatCard>, env: Env)
| 2 | import type { ChatCard } from './types/GoogleChatApi' |
| 3 | |
| 4 | export const queue = async (batch: MessageBatch<ChatCard>, env: Env) => { |
| 5 | for (const message of batch.messages) { |
| 6 | if (env.FEEDBACK_URL) { |
| 7 | try { |
| 8 | await fetch(env.FEEDBACK_URL, { |
| 9 | method: 'post', |
| 10 | body: JSON.stringify(message.body), |
| 11 | }) |
| 12 | } catch (error) { |
| 13 | message.retry() |
| 14 | } |
| 15 | } else { |
| 16 | console.log('would have posted to feedback URL', message) |
| 17 | } |
| 18 | } |
| 19 | } |