(review: {
thread_ts: string;
verdict: 'ok' | 'suspicious' | 'malicious';
reason: string;
domain: string;
action_taken?: string;
})
| 240 | * Post Addie's review assessment as a thread reply. |
| 241 | */ |
| 242 | export async function notifyAddieReview(review: { |
| 243 | thread_ts: string; |
| 244 | verdict: 'ok' | 'suspicious' | 'malicious'; |
| 245 | reason: string; |
| 246 | domain: string; |
| 247 | action_taken?: string; |
| 248 | }): Promise<void> { |
| 249 | const channelId = getChannelId(); |
| 250 | if (!channelId || !isSlackConfigured()) return; |
| 251 | |
| 252 | const verdictEmoji = review.verdict === 'ok' ? '✅' |
| 253 | : review.verdict === 'suspicious' ? '⚠️' |
| 254 | : '🚨'; |
| 255 | |
| 256 | const verdictLabel = review.verdict === 'ok' ? 'Looks good' |
| 257 | : review.verdict === 'suspicious' ? 'Suspicious' |
| 258 | : 'Malicious'; |
| 259 | |
| 260 | let text = `${verdictEmoji} *Addie review (${verdictLabel}):* ${review.reason}`; |
| 261 | if (review.action_taken) { |
| 262 | text += `\n_Action: ${review.action_taken}_`; |
| 263 | } |
| 264 | |
| 265 | const message: SlackBlockMessage = { |
| 266 | text: `Addie review: ${verdictLabel} - ${review.domain}`, |
| 267 | thread_ts: review.thread_ts, |
| 268 | blocks: [ |
| 269 | { |
| 270 | type: 'section', |
| 271 | text: { type: 'mrkdwn', text }, |
| 272 | }, |
| 273 | ], |
| 274 | }; |
| 275 | |
| 276 | try { |
| 277 | await sendChannelMessage(channelId, message); |
| 278 | } catch (error) { |
| 279 | logger.error({ error, domain: review.domain }, 'Failed to send Addie review notification'); |
| 280 | } |
| 281 | } |
no test coverage detected