package clientnotify // chooseChannel decides which channel (if any) a notification should go // out on for one client. Telegram, MAX, and VK are all free/rich and // preferred over SMS whenever linked and not opted out — the fixed // telegram > max > vk preference order (rather than e.g. most-recently- // linked) purely keeps existing behavior unchanged for deployments that // predate MAX/VK support, not because either is worse. SMS is a paid // fallback, opt-in per client AND enabled globally (an owner might not have // SMS.ru credentials configured at all). func chooseChannel(tgChatID, maxChatID, vkChatID string, notifyTelegram, notifyMax, notifyVk, notifySMS, clientNotifyEnabled, smsEnabled bool) (string, bool) { if !clientNotifyEnabled { return "", false } if tgChatID != "" && notifyTelegram { return "telegram", true } if maxChatID != "" && notifyMax { return "max", true } if vkChatID != "" && notifyVk { return "vk", true } if notifySMS && smsEnabled { return "sms", true } return "", false } // dedupeKey ties a notification to the specific event that triggered it // (an order_events.id, a warranty date, etc — see Event.DedupeSeed) plus // the channel, so a retry of the same event never double-sends but the // same trigger firing again later (order re-enters "ready" after being // reopened) produces a new key and a new message. func dedupeKey(trigger, seed, channel string) string { return trigger + ":" + seed + ":" + channel }