fix(alerts): проверять правила и группы до замены конфигурации
This commit is contained in:
1 parent
3556a378f2
commit
6093442bcf
10 files changed
+61
-10
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import {normalizeAlertsConfig} from "@mmapp/contracts/alerts"
|
||||
import {sendTelegramRequest} from "./alerts-telegram-send.js"
|
||||
import {executeTelegramSettingsUpdate} from "./alerts-telegram-settings.js"
|
||||
import { asc, desc, eq, sql } from "drizzle-orm"
|
||||
@@ -206,7 +207,9 @@ export type ReplaceAlertGroupInput = {
|
||||
/** Атомарно заменяет группы, правила и строки targets. */
|
||||
export async function replaceAlertsConfig(payload: { groups: ReplaceAlertGroupInput[]; rules: ReplaceAlertRuleInput[] }) {
|
||||
const now = sql`now()`
|
||||
const { groups, rules } = payload
|
||||
const normalized = normalizeAlertsConfig(payload)
|
||||
const groups = normalized.groups!
|
||||
const rules = normalized.rules
|
||||
await db.transaction(async (tx) => {
|
||||
await tx.delete(alertRuleConditions)
|
||||
await tx.delete(alertRuleTargets)
|
||||
|
||||
Reference in new issue
Block a user