File size: 560 Bytes
8d88d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { env } from "$env/dynamic/private";
import { logger } from "$lib/server/logger";

export async function sendSlack(text: string) {
	if (!env.WEBHOOK_URL_REPORT_ASSISTANT) {
		logger.warn("WEBHOOK_URL_REPORT_ASSISTANT is not set, tried to send a slack message.");
		return;
	}

	const res = await fetch(env.WEBHOOK_URL_REPORT_ASSISTANT, {
		method: "POST",
		headers: {
			"Content-type": "application/json",
		},
		body: JSON.stringify({
			text,
		}),
	});

	if (!res.ok) {
		logger.error(`Webhook message failed. ${res.statusText} ${res.text}`);
	}
}