| 1 | import { db, settings } from "@struxa/db"; |
| 2 | import { env } |
| 3 | import { safeDecrypt } |
| 4 | |
| 5 | const TIMEOUT_MS = 8000 |
| 6 | |
| 7 | export function notifyAdminsSignup(userEmail |
| 8 | void (async () |
| 9 | try { |
| 10 | const rows = |
| 11 | const s = |
| 12 | if ( |
| 13 | s.notifications_discord_enabled !== |
| 14 | s.notifications_telegram_enabled !== |
| 15 | ) { |
| 16 | return; |
| 17 | } |
| 18 | const appName = |
| 19 | const appUrl = |
| 20 | const message = |
| 21 | if (s.notifications_discord_enabled |
| 22 | const url = |
| 23 | const header = |
| 24 | const inner: |
| 25 | if (appUrl) { |
| 26 | inner.push( |
| 27 | { |
| 28 | type: 9, |
| 29 | components: [{ type: |
| 30 | accessory: { type: 2 |
| 31 | }, |
| 32 | { type: 14, divider |
| 33 | ); |
| 34 | } else { |
| 35 | inner.push({ |
| 36 | } |
| 37 | inner.push({ |
| 38 | inner.push({ |
| 39 | await fetch(url |
| 40 | method: "POST", |
| 41 | headers: { "Content-Type": |
| 42 | body: JSON.stringify |
| 43 | flags: 32768, |
| 44 | allowed_mentions: { parse: [] |
| 45 | components: [{ type: |
| 46 | }), |
| 47 | signal: AbortSignal.timeout |
| 48 | }); |
| 49 | } |
| 50 | if ( |
| 51 | s.notifications_telegram_enabled === |
| 52 | s.notifications_telegram_bot_token && |
| 53 | s.notifications_telegram_chat_id |
| 54 | ) { |
| 55 | const token = |
| 56 | await fetch(`https://api.telegram.org/bot |
| 57 | method: "POST", |
| 58 | headers: { "Content-Type": |
| 59 | body: JSON.stringify |
| 60 | signal: AbortSignal.timeout |
| 61 | }); |
| 62 | } |
| 63 | } catch {} |
| 64 | })(); |
| 65 | } |