mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: notifications to specific Telegram topics
This commit is contained in:
@@ -65,6 +65,7 @@ export const telegram = pgTable("telegram", {
|
||||
.$defaultFn(() => nanoid()),
|
||||
botToken: text("botToken").notNull(),
|
||||
chatId: text("chatId").notNull(),
|
||||
messageThreadId: text("messageThreadId"),
|
||||
});
|
||||
|
||||
export const discord = pgTable("discord", {
|
||||
@@ -169,6 +170,7 @@ export const apiCreateTelegram = notificationsSchema
|
||||
.extend({
|
||||
botToken: z.string().min(1),
|
||||
chatId: z.string().min(1),
|
||||
messageThreadId: z.string()
|
||||
})
|
||||
.required();
|
||||
|
||||
@@ -181,6 +183,7 @@ export const apiUpdateTelegram = apiCreateTelegram.partial().extend({
|
||||
export const apiTestTelegramConnection = apiCreateTelegram.pick({
|
||||
botToken: true,
|
||||
chatId: true,
|
||||
messageThreadId: true,
|
||||
});
|
||||
|
||||
export const apiCreateDiscord = notificationsSchema
|
||||
|
||||
@@ -122,6 +122,7 @@ export const createTelegramNotification = async (
|
||||
.values({
|
||||
botToken: input.botToken,
|
||||
chatId: input.chatId,
|
||||
messageThreadId: input.messageThreadId,
|
||||
})
|
||||
.returning()
|
||||
.then((value) => value[0]);
|
||||
@@ -193,6 +194,7 @@ export const updateTelegramNotification = async (
|
||||
.set({
|
||||
botToken: input.botToken,
|
||||
chatId: input.chatId,
|
||||
messageThreadId: input.messageThreadId,
|
||||
})
|
||||
.where(eq(telegram.telegramId, input.telegramId))
|
||||
.returning()
|
||||
|
||||
@@ -68,6 +68,7 @@ export const sendTelegramNotification = async (
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
chat_id: connection.chatId,
|
||||
message_thread_id: connection.messageThreadId,
|
||||
text: messageText,
|
||||
parse_mode: "HTML",
|
||||
disable_web_page_preview: true,
|
||||
|
||||
Reference in New Issue
Block a user