Implement Telegram notification features for payment expiry and new tariffs
- Added functionality to send Telegram notifications for upcoming payment expirations and new tariffs. - Enhanced `runScheduledSync` and `runScheduledSyncTariffs` to trigger notifications based on settings. - Updated database schema to include Telegram settings and notification preferences. - Introduced a test endpoint for verifying Telegram notification setup in the settings page. - Improved user interface in the settings page to manage Telegram bot token and notification preferences.
This commit is contained in:
+13
-1
@@ -51,7 +51,14 @@ async function fetchApi(path, options = {}) {
|
||||
...options,
|
||||
})
|
||||
if (!res.ok) {
|
||||
const err = new Error(res.statusText || 'API error')
|
||||
let message = res.statusText || 'API error'
|
||||
try {
|
||||
const data = await res.json()
|
||||
if (data?.error) message = data.error
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
const err = new Error(message)
|
||||
err.status = res.status
|
||||
err.response = res
|
||||
throw err
|
||||
@@ -156,3 +163,8 @@ export async function testApiConnection(apiBaseUrl, apiCredentials) {
|
||||
export async function fetchSyncStatus() {
|
||||
return fetchApi('/api/sync/status')
|
||||
}
|
||||
|
||||
export async function sendTelegramTestNotification() {
|
||||
const res = await fetchApi('/api/settings/telegram/test', { method: 'POST' })
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user